I want to have the people in my scene perform random animations - can I do this with a list? I have a list of people and made a function called “randomMovement” with a screen item parameter “target” - I can use the Move block to move “target”, but I would like it to perform a random animation instead of moving, but I can’t figure out a way.
The play animation CoBlock doesn’t take variables. So if you want to play random animations from the list, you can use TypeScript:
let objects = [“Casual girl”, “Casual boy”];
let animation = [“Run”, “Skip”];
let objName = objects[Math.floor(Math.random()*objects.length)];
let animationName = animation[Math.floor(Math.random()*animation.length )];
(Scene.getItem(objName) as AnimatedItem).animation.play(animationName)
Feel free to remix this example and explore the code:
@Nikolay, is there a way to get a list of the animations available for an Item, in the API? (I searched for this, but couldn’t find any publicly-exposed method).
There is no such method at the moment. I will add it to our feedback board.