#7 Jumping Animation - Unity Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
first I'm gonna go to mix mo command look for a jump animation maybe this but I'm not going to download the entire animation I'm gonna trim it trim is a cool feature for mix mo because I'm gonna divide the animation into three parts first I want just the jump let me adjust the slider forty maybe thirty nine percent forty looks good so I want the animation from right where he leaps off up to about here I think that might be somewhere around fifty percent maybe a little more fifty three so forty to fifty three percent would be the middle of the jump I'm gonna write it down because I want to remember it forty to fifty three would be the actual jump and zero to 39 percent would be the jump preparation stage and somewhere around fifty four to the end of the animation would be landing so I'm going to download this or sixty frames I'm gonna rename it jump now I'm going to go back to Mexico and I want zero to 39 percent zero to 39 okay this would be the beginning stage I'm gonna name it jump normal prep then I'm gonna go back and I want to rest at the animation maybe 55 maybe 56 58 okay so that would be the landing I'm going to name it jump normal landing so now I have one animation divided into three I'm now gonna drag it into my unity folder I remember I had a folder just for maximal so I'm gonna drag three of these things in there then I'm gonna go into each of them and change the rig to humanoid so jump normal I'm gonna switch the to humanoid go to configure turn it into a sample T bind pose click apply and I don't want the materials and I'm going to be named it here as well child normal and these settings I will take a look later so I'll click apply and play the animation I shall want to change this now change it into center of mass oops original okay that looks better then I'm gonna do the same thing with all the other animations change it to humanoid fly first configure sample T pine pose apply done and I'm also going to rename the animation this is jump normal landing let me fix some of the settings here and click PI okay I forgot to change the material we don't want any so landing is done I'm gonna go to jump prep change the rig first humanoid apply figure pose done rename and change a bit of settings apply check the animation okay looks good and I'm going to change the materials before I run the animation I gotta fix the code first let me go into character state and instead of just update I also want on state enter as well as on state exit okay I'm gonna look for the state the character state was it called state data and I want each of the states to override on enter as well as on exit with the same parameters as update okay let me look at the character state again animator state info I also want this variable as a parameter so I'm going to add it here animator state info we just call it state info for short and I'm gonna do the same thing with all three of them and once I saved this I got to fix the code in the character state just got to fix it accordingly animator state of info [Music] and I'm going to do the same thing with enter the thing that I did with update for each of the state data be in the ability list I want all of them to say on enter and I'm gonna pass on the same parameters info okay and I'm gonna do the same thing with the exit and exit and once I do this every script they inherits from the state data has now got to follow this format you should now give me an error message a few so I got to go in there and fix it and do the same thing and state info I was also going to have on enter and on exit as well save and go back to unity I have one more and I do the same thing so this one is move forward okay the errors are now gone now I'm gonna go to keyboard input because I want a new button for the jump and I'm gonna use space so if get input and space is press you want the virtual input manager to say state jump is true except the virtual input manager doesn't have a variable called jump so I'm gonna go in there to the virtual input manager again f12 means you're gonna go to the definition and I'm gonna say to jump it's now another variable for the input manager I'll go back to the keyboard script this single bracket there if space is not pressed and then jump is false I'm also going to go into the manual input and pretty much do the same thing if virtual input manager says jump is false then I want the character control to say jump it's false but again the character control does not have a variable called jump so I'm gonna find the character control here it is and I'm going to add variable there I am gonna go back to the manual input and say if jump is not pressed then jump is false okay let me just check the buttons so when I press space jump is not coming up that means I did something wrong here oh this should be true okay let me go back and test it so every time I press space jump gets checked now I'm gonna go into the animator for a character and then I'm gonna add the parameter here as well bull you know call it jump as well and now I'm gonna drag in the animations these three jump prep jump and landing basically we're gonna go from idle to prep to jump to land and back to idle so I'm gonna go into the idle script and say if the virtual input manager oh no I'm not going to use the virtual input manager I'm gonna use the character control let me fix a code below then I'm gonna say if character control says jump then we change the parameter in the animator set bull jump it's true and let me create the enum press f12 jump go back to the idle script and change this to the enum please string now I'm going to go back to unity and create a transition from idle to jump prep I'm going to look at the transition I'm going to get rid of the exit time I want the transition to be quick so I'm going to zoom in to this graph and make the transition quick then I'm going to add the condition jump so every time this comes up we're not going to go from idle to jump prep let's test it okay the character goes into the jump prep but stops there because we don't have any transition from here to any other state so now I'm going to add another transition make transition from prep to normal and again we don't want the exit time I guess we could have this relatively smooth we're gonna need another condition here so I'm gonna go to states that script and I'm gonna say I'm gonna create a new C sharp script and call it force transition go into it and it's gonna be similar to all the other abilities so I'm gonna copy paste it and then delete this part and also gonna change the name to force transition also change the name here it's called force transition and I don't want the speed variable I want the variable that determines when you switch to the next animation own I deleted too many things so let me rewrite it we need this and instead of the speed very well we need transition timing this is going to be a percentage value so I'm gonna say it's range between 0.01 being 1% to one being 100% and then in the update ability I say if state info and the normalized time is passed in this variable that's when we switch you'll go back to unity I'm going to add the new parameter to the animator bull call it force transition so I'm going to go back to the script and say animator will change the parameter horse transition and call it true upon exit we want to turn it back to false and again let me change the string into enum ports transition switch it here okay now go back to unity and I'm gonna add the condition force transition I'm gonna go to the state's folder and create a new object called force transition and call it player jump normal force transition and I'm going to adjust the slider I'm gonna try 80% for now so 0.8 means 80% I don't need this variable I'm gonna get rid of it go to state data don't need iteration I need to add that object to this state so I'm going to add the character state I'm going to add the ability force transition okay so we're gonna go from idle to prep and when that prep animation reaches 80% it's gonna go into the jump animation I see if it works I'm gonna press space prep to jump and again we're stuck at jump because there are no transitions from here so click play again to exit and I'm going to add another transition okay adjusts the curves landing is a little tricky because we got to figure out when the character hits the surface so for now we're just going to leave it as exit time and do the same thing make a transition to idle and just set up the curves and we're going to leave it as is for now so let's test what we have okay so we're going from idle to prep to normal to land except it seems to be in an infinite loop looks like the jump parameter is always on so I'm going to exit and I'm gonna create a script for landing I'm gonna go to state scripts and I'm gonna say a new c-sharp script is called land landing I'm gonna go in there and it will be kind of like idle so let me copy it copy paste everything get rid of the update yeah and I'm just gonna change the name to landing then I'm gonna say when to kak the lands you want the animator to set bull jump is now going to be false save and go back to unity I'm gonna go to the states and create the new ability create landing I'm going to name it player jump normal landing okay yeah I'm gonna click on the state and the behavior add character state one ability its landing let's test it okay that's good so the character jumps and then when he lands jump is now false so you got a press jump again for it to work let me look at it from the scene view the preparation stage seems way too slow so I'm gonna go to the end go to the animator and speed it up I'm gonna say speed is to let me play it again it's a little better but it's still kind of slow I'm gonna go into the animation itself and I want it to start at maybe 10% click apply let me try again seems a little better it's it's way faster now Landing also seems to be slow so I'm going to double the speed I like that better but the feet are not aligned so I'm gonna go into the animator and click on foot I K on everything this should align the feet a little more to the ground we take a look again I think I need to edit the animations a little bit so go into prep the orientation didn't seem to match so maybe 10% here 10 degrees here Idol seems a little bit high bring it down a little bit oh no that's not here bring it down a little bit here that's the right spot I'm gonna go to prep and I'm gonna bring it up a little bit prep seems okay but the landings a little weird so I'm gonna change it here turn it 10 degrees and bring it up just a little bit I'm going to exit play mode and I'm gonna add another force transition for the landing force transition where you jump normal landing force transition that's a long name but I don't know what else to call it again maybe I'm gonna try 80% creating another slot and add in the force transition let me try it again Haidee might not be enough oh we haven't added the parameter yet and we gotta get rid of the exit time so let me try again okay that's a little too much forty five percent seems a little better for me let me change the graph here I'm gonna make it a little smoother it's a subtle difference but I like this much better the problem with this is that the character is not actually moving yet it's just the animation this collision detector is staying at the same spot only the animation is playing but I think we've already done a lot for one video I think I'm gonna leave the physics part to the next video so thanks for watching I'll see you guys soon
Info
Channel: Roundbeargames
Views: 41,251
Rating: undefined out of 5
Keywords: game dev, game development, unity, unity game development, unity tutorial, unity3d, unity jump, unity jumping tutorial, jumping animation, 2.5d, unity3d tutorial, roundbeargames, unity 3d, 2.5d sidescroller, sidescroller, unity sidescroller, unity 2.5d sidescroller, unity jumping, jumping, jumping in unity, tutorial, game development course, game development course by roundbeargames, course by roundbeargames, indiegamedev, animation, unity animations, animations, course
Id: 6Zg2Hgwg7OM
Channel Id: undefined
Length: 26min 26sec (1586 seconds)
Published: Mon Apr 08 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.