Among Us Idle And Run Animation Unity Software Tutorial | Top Down Movement In 2D Unity Game

Опубликовано: 07 Октябрь 2024
на канале: Alexander Zotov
6,426
169

#AmongUs #UnityAnimation #UnityIdleRun
Episode 1. Among Us Idle And Run Animation Unity Software Tutorial

Very good gaming mouse for the price!
Logitech G203 Wired Gaming Mouse
https://amzn.to/2VBgNQA

TO BLAST! - My New Fun Relaxing Puzzle Game Available On Google Play Store
https://play.google.com/store/apps/de...

Consider purchasing my ULTIMATE UDEMY COURSE with a great discount https://www.udemy.com/how-to-make-gam...

Following Videos

Episode 2. Give Among Us A Weapon Pistol & Shotgun    • Give Among Us A Weapon Pistol & Shotg...  

Episode 3. Fire Pistol And Shotgun Switching Them Back And Forth    • Fire Pistol And Shotgun Switching The...  

Episode 4. Create Enemy Run Animation    • Create Enemy Run Animation For Among ...  

Episode 5. Make Enemy Follow The Player    • Make Enemy Follow The Player In 2D To...  

Episode 6. Spawn Enemies At Random Position With Random Color In Among Us 2D Shooter Clone Made With Unity    • Spawn Enemies At Random Position With...  

Episode 7. Kill Or Destroy An Enemy With A Bullet.    • Simple Way To Kill Or Destroy An Enem...  

Character here https://drive.google.com/file/d/10CKK...

Hi!
In this short video I show you a very simple way to animate your character in a Top down game like Among Us.
Here I have an empty project and a blue character sprite which you can get by the link in the description by the way. First of all I need to slice it to separate images. Sprite mode to Multiple and hit apply. Now I go to the sprite editor. Nice guy. I go to Slice menu. I’m going to slice it in automatic mode. So I select it and hit slice button. My sprite sheet is sliced now. But here is one wrong piece of picture. I delete it. And expand this slice down to the bottom. Make sure the right edge of the slice is near enough to the sprite. That’s good enough. Hit apply to apply the changes. One important thing about sprites pivot points. To make animation go correctly I need to place this pivot point at the bottom of the sprites. Just like so. Same for the rest of the sprites. Another important thing here is to make sure that pivot point is positioned at the same place of each sprite. If those pivot points don’t match then the animation will jitter. You will not have this problem if your sprites have the same width. But as you can see sprite number four and sprite number five have different widths. That means that their pivot point should be shifted. So I shift those points a bit to the left. We will see if its enough later when animation is created. Hit apply to save the changes. Here are my sprites. I take one and put it to the scene to create a character. Scale it down a bit. It’s time to create animations.

Make sure the character is selected and go to animation window. Click create new animation button. I save it into animation folder and name this first animation as IdleAnim. Animation name is important because this name will be used in the script. Ok. Take first sprite and D&D it to the timeline. Idle animation is done. Create new animation clip. THis will be Run Animation. Name is important as well. Here I have to create a correct sequence of the sprites. I already know that sequence so I just drag corresponding sprites into timeline in certain order. Like this. Hit play to check it out. If you think your animation plays to fast you can slow it down by reducing sample rate here. Don’t forget to hit enter. Cool. Now back to pivot point. As you can notice the third sprite in sequence is shifted to the left a bit. That’s because of the incorrect pivot point position of this particular sprite. Thankfully we can easily fix this. Select the sprite sheet, go to the sprite editor, select the sprite we need to fix and shift the pivot point a bit in X axis. Hit apply. Check it out. Almost perfect now. Animations are ready.

Now it’s time to check the script that will make this all work. It's a pretty simple one. Here are some variables which are initialized in the start method. Local scale will help us to flip character left and right. In Update we read input from arrow buttons and perform animation control. In fixed update we pass a velocity to rigidbody depending on our input. And in Late update we face the character left or right depending on where he goes altering his local scale by X axis. In animation control method we play corresponding animations depending on velocity of the character. In X and Y velocity is zero the Idle animation is played. If either X or Y velocity isn’t zero then run animation is played. That’s the script. Script goes to character. I hit play to see how it works and immediately get a bunch of errors which means that I forgot to add a rigidbody 2d component to the character. I do so and set gravity scale to zero so my character will not fall down. Take two. Works great! Hope you like this tutorial. Thank you for watching and see you next time.