0

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'));
    }
Harry
  • 1,021
  • 4
  • 21
  • 41

1 Answers1

0

You are using the correct method (<entity>.getAttribute()), but at the time setup() is called your state machine won't have actually been started. Try putting that code in your update() 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"?

Kris Schultz
  • 606
  • 1
  • 5
  • 9