How do I trigger a custom animation when the player is idle?

Get help using Construct 2

Post » Wed Mar 18, 2015 8:49 pm

Hi,
I want to make the player character to play a custom animation only when the player is idle let's say, after 5 seconds the player has been idle, without moving.
If you move the player the custom animation should dissapear.
I've tried different methods without success. The problem is the "wait" event. it triggers the animation even after I've moved the player.

Any suggestions? I've attached my events sheet.

Thanks!
You do not have the required permissions to view the files attached to this post.
B
5
S
1
Posts: 42
Reputation: 471

Post » Wed Mar 18, 2015 9:17 pm

One work around:

Make a global variable called something like TimeSincePressed, have it increment (using Add to variable) 1 per second (using Every X Seconds) and reset it to 0 each time a movement or jump key is pressed and also when it is released (since it is very unlikely someone would move in a direction on a platformer continually for over 5 seconds.. if so you have some serious boring gameplay :)). Have your Idle event not do a wait but simply check every tick for the value of TimeSincePressed and if greater than or equal to 5 then fire it off and if lower ignore via a return in else statement.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
63
S
17
G
8
Posts: 629
Reputation: 9,269

Post » Thu Mar 19, 2015 7:04 pm

It worked!

Thanks!
B
5
S
1
Posts: 42
Reputation: 471


Return to How do I....?

Who is online

Users browsing this forum: BackendFreak, R0J0hound and 1 guest