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'));
    }
4

1 回答 1

0

您正在使用正确的方法 ( <entity>.getAttribute()),但在setup()调用时您的状态机实际上并未启动。尝试将该代码放入您的update()方法中,看看您是否得到不同的结果。

对于你的第二个问题,你能否解释一下当你说“从另一个脚本访问变量”时你的意思?

于 2019-01-27T04:24:33.177 回答