Is there a way to work out whether a character is idle?

What would you define as idle? No movement or rotation after a period of time? No input events after a period of time?

I would recommend creating a float within your SideScrollerCharacter. On tick add the delta value to the new parameter. If it goes above a certain threshold you can start the damage.

When movement/jump input is triggered you can reset the float to 0.

Hi all,

I’m new to Unreal Engine and I’ve been trying to work this out and Google all over the internet but I can’t seem to find an answer. I’m trying to make it so when my character is idle, he will slowly lose stamina. I’ve created a stamina bar that works and everything, but I’m not to sure how to check whether my character is idle or not, with the blueprints? And if so, then decrease the stamina in the stamina meter. Is there a way to do this?

Thank you in advance!

Forgot to add this but I’m adding this now, I’m creating a simple 2D side scrolling game with Unreal’s 2D side scrolling mode

I realised I didn’t mention that I’m making a 2D side scrolling game, in the question. I just updated it as I obviously don’t care about the z axes.

I would define idle idle as no movement at all (No jumping, no moving left or right). Other input by pressing random keys or moving the mouse shouldn’t be able to override this affect and stop the player from losing stamina.

Have any ideas?

I just tried that but whenever I run it and stand still, I can see in my blueprints that the character is always moving, even when I’m idle so therefore I can never execute the stamina decrease?

So I’m sorry for being such a newbie, but what am I doing wrong?

That should do the trick. I didn’t realize that InputAxis MoveRight ticked every frame when the axis was 0.

You want to set idle time to 0.0 if the second branch of your input function is true. Right now you’re setting idle time to 0 if the axis 0.

I tried that but whenever not moving, it doesn’t set idle time to 0?

You don’t want to set the idle time to zero if you’re not moving. The idea is to tally up time in your tick function, only resetting the variable if we detect input. If the axis value is 0, then we don’t want to reset the idle time.

You’re also going to want to set the idle time to zero if the first branch is true.

Okay so I set the idle time to zero for the first branch but how do I make the idle time float tally up?

I tried that but since there’s already an “Event Tick” used for animations I can’t add a new one?

I deleted the animation “Event Tick” and created a new matching yours and it still doesn’t work? I feel like I’m missing something really simple…