Posted July 30, 2023 by Siderun
For this week's tutorial, I added my character into Unity and made it walk. Not only that, but I also checked if the character was moving, to determine if the walking animation played or not.
To do this, I added a Boolean into my animation controller that checks if the character is moving or not. Then, inside my character's control script, I had it check every frame to see if the character is moving on the vertical axis (that is, forwards and backwards). If it is, it sets the walking Boolean true, thus triggering the walking animation. If not, it's set to false, setting the animation back to idle.
A tricky part of this was to make sure the change from walking to idle, and vice versa, was instantaneous. To do this, inside the animation controller, I disabled the exit time for both transitions.