As a property, I have an array of entities.
Each entity contains a Tween script for animations.
How can I access each script individually, so far I have done that with event like app.fire and app.on
As a property, I have an array of entities.
Each entity contains a Tween script for animations.
How can I access each script individually, so far I have done that with event like app.fire and app.on
Hi @Dava,
You can easily access a script instance on any entity that has that script type attached like this:
// here we have an array of entities
entities.forEach( function(entity){
// we access a script instance and update a property
entity.script.myScriptName.speed = 3;
});
It’s not working for me
In this code, I am calling a function from another script
and this is error i get
Hi @Dava,
Can you check at the top of your script if the script type name is indeed TweenMove
or maybe it’s tweenMove
?
Also make sure to call in the following manner:
// entity object -> script component -> script type -> method
entity.script.scriptTypeName.methodName;
this.MainButtons[i] = my entity
TweenMove = name of the script
AnimTo = function
what is scripttypename ?
var Mouse = pc.createScript('mouse');
Here, scriptTypeName
is mouse
(the one from the brackets) and not Mouse
.