How do I start a new Random Animation

Get help using Construct 2

Post » Wed Jul 06, 2016 4:14 am

what I want to accomplish is have a sprite go to a random animation, between and including "animation1" to "animation7"

I can use
Set animation to choose("animation1",animation2",animation3",animation4",animation5",animation6",animation7")

to get that result, however in my project after completing the game, it will loop back to the first layout, and I'd like to pick out another random animation, but not have the one played first time, play again.

Is there anything I can add to the code to say, if a variable stating "animation1 has played" is set to 1, don't include that animation in the random list next time it picks?

I had started writing that out with the "animation1" missing like:
System "Animation1 = 1"
Set animation to choose("animation2",animation3",animation4",animation5",animation6",animation7")

but as it goes on it gets more complicated since any combination of the animations could have played at the next loop of the game.

Any advice would be appreciated! :)
B
16
S
4
Posts: 50
Reputation: 1,035

Post » Wed Jul 06, 2016 2:37 pm

You could use an array (width 0) and push all all the animation names along X. Then pick a random one (Array.At(random(Array.Width-1))) and delete the element after that.
B
23
S
6
G
11
Posts: 1,047
Reputation: 8,065

Post » Fri Jul 08, 2016 1:25 am

Thanks for the reply,
I've never done anything like that but I'll give it a go!
B
16
S
4
Posts: 50
Reputation: 1,035


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 33 guests