The 3D Game Kit has animations for moving around, such as run/walk forward etc and these animations have footstep sounds associated with them.
I’m wondering how this is achieved, as I have scoured the documentation and it is not described. I found hints at how this is accomplished, but I’m not 100% on it.
It seems that there is a dopesheet variable called “Animator.Foot Fall” (shown in attachment) which has some keyframes which updates the animator variable called “FootFall”. The PlayerController decides to play a sound based on the value of FootFall.
Does the animation update the animator parameters automatically?
What value is used to set the value of Footfall in the animator parameters?
If I set a dopesheet variable & keyframes, can I reference this variable in the animator parameters by just removing the space or something?
I have adopted events to make footstep calls, which works just fine, however I’m a little stumped over the above behaviour as I can’t seem to find any documentation describing what is happening.
This image shows the dopesheet for Animator Foot Fall at the top with two sets of 3 keyframes.
Looking closer at the image, yeah, it looks like the animator’s Foot Fall parameter is animated by the animation clip. That’s… interesting. I’ve never seen anyone do that before.
Animations made in the Animation window can animate arbitrary values, as long as they’re serializable by Unity, so yeah, it’s getting moved by the animation itself.
They’re using Animation Curves to change the value of FootFall.
That’s what’s controlling the footstep sounds. In the main PlayerController script there’s a PlayAudio method which uses the FootFall parameter.
To see those curves, first select the .fbx asset where the animation is located.
Then, at the Inspector window, select the correct animation clip if needed.
Finally, scroll down and open the Curves option. In this case, the curve is directly setting up the value of the Animator parameter FootFall, based on the animation’s current frame.