Hi, I’m trying to move a ‘score’ entity once a ‘Digit’ is enabled. This is so it is always centered at the top of the screen. I have tried the code below:
var app = this.app;
var Digit2 = this.entity.findByName('Digit 2');
var Digit1 = this.entity.findByName('Digit 1');
var Digit0 = this.entity.findByName('Digit 0');
if (Digit1.enabled === true) {
Digit2.setLocalPosition(0.02, 0, 0);
Digit1.setLocalPosition(-0.02, 0, 0);
}
if (Digit0.enabled === true) {
Digit0.setLocalPosition(-0.025, 0, 0);
Digit1.setLocalPosition(0, 0, 0);
Digit2.setLocalPosition(0.025, 0, 0);
}
Doing this got the error: TypeError: undefined is not an object
Any help?
Not really much of an expert in errors, but you may wanna try getting the entities using attributes instead. Undefined means that a variable isn’t assigned. If this doesn’t help, try reaching out to @will or @yaustar for help.
The issue seems to be that the definition of the flow type for _setComponentRef not only defines the type but also initializes the value with undefined .
_setComponentRef: Function;
This is probably a babel setup error, most likely around @babel/preset-flow and/or @babel/plugin-proposal-class-properties .