Make A Game Like Pokemon in Unity | #2 - Player Animations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome to part 2 of 4 come on cable our Series in unity so in this video we will look at how to implement animations so if you open the character sprite sheet in the strike editor you can see that we have all the frames to create walking animations in all four directions so let's create the animations first open the animation window in your window animation then we just rearrange the window layout like to keep this layout when I'm animating because I want to be able to see the project animation and the scene window at the same time so we need to create an idle animation and a walk animation for all the four directions so click on the player and in the animation window they can't create I've created a folder to store our animations and I'll name some mission idle down and drag the first frame from the character spreadsheet this animation okay so idle animations are animations with only one frame so now let's create a walk down animation click on create new clip I've called this fork down so for the faulkner animation we will use sprites from character zero to character three okay so these are all the strikes we need for our worked out animation so drag these four to our animation window and if you hit play and see that the animation is like really fast so in order to slow it down we can reduce the sample rate so if you don't see sample rate in your animation window just click here and select show sample rate so I've seen the sample rate to six and now if you play the animation you can see that the animation is much more slower which is what we want okay so next we'll create idle up and walk up animation call it idle up so you can actually open the character by sheet in the sprite editor and find the idol up sprite and when you click on it you can see its name so it's character 24 so we just have to find character 24 so here it is I'll drag that to the animation window and I'll create backup animation so for walk-up animation we need sprite from 24 to 27 so these are the sprites I'll bring them in and just like before we'll change the sample rate to 6 and hit play so you can see that it is animating correctly next I'll create idle right and I will try to sprite is actually 13 so I'll drag that in next I'll create Bach right so walk ride is from 13 to 16 I'll drag them in and change this number 8 to 6 is animating correctly next I'll make idle left so let's find the idealist sprite it's certified ok I'll drag them into the animation window and next I'll create or Clift so walk left left is from 35 to 38 in the sample rate to 6 and the animation is playing currently so we have created all the animations that we need so let me just change the layout back to normal now if we look inside our animation here we can see all the animations that we created and there is also an animated controller in here the UTS automatically created this for us and if you click on the player game object you can see that a new component called animators added and it's actually referencing this controller so open the animator controller animate controls are used to transition between multiple animations so it's very specified when to play walking animation idle animation and all that so instead of manually creating transition between all our animations we'll use something called blend tree to do that for us so let's delete all these animations from the controller and first we need to create two float parameters mu X animal Y so these parameters will control which animations should be played and people set these parameters from our playercontroller script now let's create a Glen tree right click click on create state and from new blend tree here I'll name the blend tree as idols and double-click to open so first we will change the blend type to 2d simple directional choose mu X as the first parameter and mu Y as the second parameter and add for motion fields I will add idle down to the first motion field I will up to second I left blue third and idle right to the fourth so the blend tree will decide which of these animations to play based on the value of x and y so here we need to specify the value of modes in the Y at which each animation should be played so idle down should be played when x is 0 and Y is minus 1 idle up should be played when x is 0 and Y is 1 idly left should be played when X is minus 1 and y is 0 and finally I will write should be played when X is 1 and Y is 0 okay so now if we change the MOOCs and more value you can see that the blend tree changes the animation so when more X is 1 its right just like we specified here and random works is like minus 1 its left and similarly when mu Y is 1 it's up and down 1 minus 1 ok so now let's try to set these parameters from our air controller okay so first we need to cache the reference to our animator controller so we cashed at our in-studio animator from the awake function and now if the input is not 0 then we will set the move X and no y parameters of the animated I'll use the central function of the animator a most parameter is move X and the value is going to be input dot X do the same for y okay so now if we test again and we move right the idol right animation will be played then we move left the idol left hand machine we played and same with up and down and since we are like only setting move ox and away if the input is not zero the player will stay in the previous animation when we are not moving so and I press left this will be in the idle down and even when I stop moving the player will still stay in the idle left animation okay so next let's create blend tree for our walking animation so go back to base layer and here I'll create a new blend tree and call it Bach change the type to Tory this introductional those parameter should be move X and the second should be my Y I'll add for motion fields and finally we will drag the animations just like we did before so who walked on X is zero Y is minus one I walk up x is 0 and Y is one a walk left X is minus 1 and y is zero and four walk right X is 1 and Y is zero ok so now let's go back to the base layer and we need a Bay to transition between being ideal and walk animations so I'll create a boolean parameter called is moving so when s moving is true they create a transition from idle to walk so click on the transition and in the conditions change is moving through and we have to remove exit time otherwise the transition won't happen until the current animation is completed and let's also change the transition duration to zero because we want to transition instantly now let's create a transition back to idle and this should happen when it's moving is false I'll move exit time and change the transition duration to zero so now we need to set s moving from our playercontroller so we already have a variable to keep track of whether the player is moving or not so all we have to do is set that to the animator at the end of update function now let's just again so you can see that the animations are being played correctly so I stopped the video here and in the next part we will look at how to add more objects to our tile map and create a town scene so if you think this video was helpful please hit that subscribe button that'll mean a lot to me and I see you in the next video
Info
Channel: Game Dev Experiments
Views: 21,461
Rating: undefined out of 5
Keywords: make a game like pokemon in unity, how to make a game like pokemon in unity, make pokemon in unity, make pokemon game in unity, how to make pokemon game in unity, make a pokemon game in unity, unity pokemon game tutorial, top down movement in unity
Id: 3h6kZkhza3U
Channel Id: undefined
Length: 13min 20sec (800 seconds)
Published: Sun May 31 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.