Idle, Walk, and Run Animations in Unity Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
the goal of this video is to set up idle walking and running animations in unity so to start out i have a character that i imported from blender and attached to that character is a character controller an animator component that uses the player character animator that i set up and then a character controller script which controls things like the speed the jump height gravity and so forth so the script set up in a different folder open that in a minute but first let's play the game i can move the character around i can jump but you'll note that none of the animations are running because i haven't actually set them up so if i go to the animator tab which should appear once you have an animator component and then i go to my prefab for that character and i'm going to drag and drop the three animations that i imported from blender so i'll be idle walk and run then i'm going to drag the animator tab back down and now i'm going to set up transitions between the three of these animations so right click on after i set these up i'll right click on idle hit make transition and the same in reverse make transition from idle to run and then from run to idle and lastly from walk to run and run to walk this is not the most efficient way to do it but it's the easiest to understand so for these transitions i'm going to set up a parameter which i already have i hit the plus icon and then float and called it speed and then in each of these transitions i'm going to set a condition so if the speed is greater than 0.01 so if we're moving at all we want to go from idle to walk and then the inverse is true if the speed is less than 0.01 we want to go back from walking to idle and the same thing for a walk to run but this time we'll say if the speed is greater than 0.5 and then the opposite if the speed is less than 0.5 this speed value does not equate to the speed value from the character controller so even though i have the speed set to five this is just from zero to one so i've set all these up i actually removed exit time from all the transitions to better demonstrate this that as i move the speed to different values you can see that it'll execute the idle walk or run animations so now i need to actually get the speed parameter to update via the script so i'm going to go into the character controller script and you'll note that i have a vector3 for move direction and then i also have an animator value to get the animator component so also the animations here so if the move direction is vector 3.0 so if we're not moving at all we want to run the idle animation or execute the idle animation so we're going to say animator dot set float so we're going to set that speed value to zero so if we're not moving that speed value will get automatically updated to zero as we were able to do manually previously so else if we are moving so if it's not zero and we're not getting whatever the value is to run in this case would be hitting the left shift key then we want to walk so we're moving but we're not sprinting so animator.setfloatspeed and then we'll set it at 0.5 and that should make it to where we walk and then run would be basically just if we're not idling or not walking we should be running so animator.setfloat speed and we'll just set the value to one and that should be it for the script i'll show the rest of the script there if i save this go back into unity and click play again you can see my character controller there so i click play so my speed value is five but that's for the actual speed that i want the character moving that's not for what's controlling the animated controller the animator controller is just a value from zero to one to tell us whether we're idle or walking or running you can actually name that parameter something different if it makes it easier and that's pretty much it
Info
Channel: RSDevelopment
Views: 22,033
Rating: undefined out of 5
Keywords: Unity, Blender, Animations, Walk, Run, Idle
Id: 5mlwvbu1fxQ
Channel Id: undefined
Length: 5min 1sec (301 seconds)
Published: Sun Jul 10 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.