This question should be relatively easy to answer. It stems from me trying to add footstep audio to my game. I used Metasound to add the footsteps to the default arm animations from the first person template. In blueprints, I set it up so it loops the walking and running animations (and footstep audio) when the player is either walking or sprinting.
My problem is the footsteps continue to loop after the player stops moving.
I have a “Is Player Moving?” boolean ready, I’m just not sure how to set up a function for the boolean to check whether or not the player is currently moving. Once I set up the function I should be able to use the boolean to tell the animation (and audio) to loop, or not to loop, based on the player’s current movement.
A few questions to help get things started. Have you tried using animation notifies to set up your footstep audio? And which part are you missing to set up your is player moving bool? Is it checking the velocity or something else?
Any additional information you provide may go a long way in solving your problem!
Here is a very simple check example you can do using both Get Velocity and Get current acceleration that will return true if your player is moving and false if it is not.
Another solution is to check bone velocity. Maybe there are better ones, but this is the only one I found that can report velocity not only while controlled by user, but also in ragdoll.
Tried it, didn’t work for me. However, I did find a solution to my footsteps problem.
I have the footstep audio tied to the first person template’s arm animations. Took me a while to realize that “walking” in the first person template defaults to the running animation for some reason. Spent some time setting up a blend space animation to transition from walking to running, and reworking the locomotion state machine so the character transitions from idle > walking > running smoothly. That fixed my footstep audio problem for me.
I still have a problem with stamina draining when the character isn’t moving though, so I’ll try to utilize my “IsPlayerMoving?” bool to solve that. I’ll just need to figure out how to automatically cancel the toggled sprint input when the player stops moving.