I'd like to use random animation of my sprite when overlapping other object... For example randomly kick or punch animations. Thanks!
You can either way:
1. Create a variable to work as your random number, and then set the animation to happen based on that variable.
For instance, A = int(random(3)) . If A = 0 play animation "Punching", if A = 1 play animation "Kicking" and so on.
2. Set the name of all animations you want to happen randomly the same. Like, RandomAnimation1, RandomAnimation2, RandomAnimation3... you got my point.
With all the names the same try this:
On overlapping object > Set animation to "RandomAnimation" & intRandom(3)
Hope this helps
On overlapping object > Set animation to : choose("kicking","Punching")
Develop games in your browser. Powerful, performant & highly capable.
play animation : choose("kick","punch","duck","fall")
choose("item1","item2",etc) will pick one of its items randomly.
Edit: ninja'd by littlestain
I see one issue though, the choosing will be performed every tick, so the animation could change every tick..
It would probably be better to set an (instance) variable to choose() on collision and play animation = (instance) variable when overlapping...
Thanks to all! "choose" function is perfect!