How do I start a new Random Animation

0 favourites
  • 3 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply,

    I've never done anything like that but I'll give it a go!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)