Animating an item from typescript or managing the same event both in CoBlocks and Script


Is it possible animating an item from typescript without using CoBlocks or Blockly?
If not, there’s a way for managing the same event both in CoBlocks and Script… i can’t succeed in this.


Hi @mariochiesa,

do you mean playing an animation track of an item (ie. a human character), or do you mean moving the item position?


Hi @Stefan,
I can start an animation in CoBlocks, like choosing and customising a block to ‘set animation of man to Talking neutral’.
Can i start an animation through a script (Typescript odr Javascript)? This function is at least not documented…

My example:
I’m managing a slideshow totally in a Script, it works like a template… i’ve saved the script on my PC and i can copyit in a script in a new space, upload new images and soundclips, update the Ids in the template and everything works simple and fast. When i start playing a soundclip (typically a voice reading what is written in a slide… i’m testing VR for inclusive education…) it would be helpful to have the man start playing Talking neutral.

But this is just an example… controlling animation by scripts it would be very helpful in many situations…


@Stefan, sorry missed to ask this:
in the case i can control animations only in CoBlocks, can i have two events working on the same item and with the same event? like man.onActivate() in Script and ‘when man is clicked’ in CoBlocks?


Hi @mariochiesa,

the method onActivate and the CoBlock when item clicked are mutually exclusive. Only one of the two will be active at a time on a single item.

I like to share an internal method with you that allows you to play the animation track of an item. Please keep in mind that this method won’t be recognized by your code editor, but will still work. The animation name is case sensitive.

const myItem = Scene.getItem('myItemName') as AnimatedItem;