Reset a value of a float variable

Hi there,
I have implemented within my project a Footsteps System, I used a Float variable to scan the time between footsteps by adding this last variable to a Set Timer By Event, however, my project has a sprinting and crouching system and for this reason, to avoid having uncoordinated footsteps when running or crouching, I thought of changing the value of the Float variable (Footsteps Int) to solve the problem, this worked, but not as expected:
If the player is walking normally and while holding down the sprint input, the character will start to run, but the sound effect of the footsteps does not change and will continue to be the same as when the character was walking, same with regard to crouching.
This issue can be solved by releasing any input and pressing crouch or sprint input first and only then start walking; this seems very cumbersome and not fluid at all.
Is there any way to fix this issue?
I hope this makes some sense.

I attach a screen of how I reasoned:

You’re overcomplicating things. Just add Notifies to your animations at the down-step moments and play sounds based on these notifies.

Edit: Yeah, I didn’t think there might be no animations at all. My bad.

The thing is, the timer only reads the float once when set, and it doesn’t matter if you change the float. You need to restart the timer after changing the float value to force it to read the value again.

Hey there,

Oops, my mistake, I forgot to specify that the project is first person, so it doesn’t actually have a body of consequence of animations.

Don’t worry about that!

I hadn’t thought about that, other than not being able to execute it probably, do you have any tips I can follow?

Just call Set Timer again every time you change the float variable. You don’t need to stop or invalidate it if it’s active, just call the same SetTimerByEvent node.

I tried inserting a Set Timer By Event after each change in the Float variable, but maybe I missed something; I tried running a playtest and now the steps are totally gone.
I guess I didn’t put Set Time By Event in the right place.

I’ll show you:

It must be the same node. If you make another node, it’s another timer.

So, if I understand correctly, what I need to do is to move all the branches that indicate the various float values, after the Do Once that precedes the Set Timer By Event and connect all the possible nodes?

Make a custom event and use it to start and restart the timer. Then you can separate it from the chain and it will be easier to work with it.

1 Like

I think I understand the reasoning, I will immediately try to implement it and let you know how it went!

Yeah everything worked perfectly!
Thank you so much for your help and time, you were very clear buddy!

Greetings from Italy!

1 Like