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