I need help with a few things with Amazon Sumerian:
- How can I access an entity's attribute in a script?
- How can I access a variable from another script?
This is the code I tried to access an entity's variable that I set in the state machine but it returns undefined.
function setup(args, ctx) {
ctx.runButton = ctx.world.by.name('RunButton').first();
console.log(ctx.runButton.getAttribute('isReset'));
}
You are using the correct method (
<entity>.getAttribute()
), but at the timesetup()
is called your state machine won't have actually been started. Try putting that code in yourupdate()
method and see if you get a different result.For you second question, can you explain a bit more about what you mean when you say "access a variable from another script"?