How do I randomise my idle animations?

  • I am trying to set the main character idle animation to pick from several, so a breathing one, a looking around one and a twitchy one.

    What I have done is having the character while on the ground and when not moving to start the "idle", that works.

    Then I searched the forums and found a possible solution to randomize and I tried the fucntion on set the antimation "choose("a_idle","a_idle2","a_idle2"). At first it did not work and it just froze my character, then I set it it to "trigger once" it works, but it only chooses one of the three animations only after doing something else like running or jumping, so once the random has been chosen it keeps playing that animation on loop.

    Any ideas, I think the solution would be to re trigger the event over and over but I am not sure how.

    Cheers

  • Here's one way:

    1. Give the character a boolean variable: isIdle

    2. Add your idle animations: "breathing", "looking", "twitching" to the character. Make sure they're not set to loop.

    3. When your character is on the ground and not moving set isIdle to true.

    4.Add an event with these conditions and action:

    Condition: Character isIdle

    Condition: Character Compare Frame is equal to Character.AnimationFrameCount-1,

    Action: Set Animation to choose("breathing", "looking", twitching) from beginning.

    Remember to switch isIdle to false when the character starts moving or is off the ground.

  • Thanks! I have tried your instructions but could not make it work, perhaps I did not do something right, however your suggestion of removing loop is what was causing the issue, originally, without loop my first idea now works :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 'is not moving' with a trigger once and set animation should work. If it's not working then you have conflicting events that are true at the same time which is common with animation logic. Also you don't need an additional bool isIdle when there is platform behaviour condition isMoving which you can use.

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