Animations

Starting off with putting animations in a unity project, you will need a spritesheet, this sprite sheet has been provided for me from my designer in my game group. This sprite sheet contains 12 frames for a running animation. To make sure you get optimal results from using a spritesheet, make sure you have the background transparent and each from as consecutive, reasonable resolutions.

To make this into a functioning animation, we need to tell unity to make it into a animation. To do this you will select the Texture Type to be Sprite (2D and Ui) and select Multiple from the Sprite Mode dropdown list. Press apply.

After this, click the Sprite Editor buttona and unity should come up with a pop up with your spritesheet on it. Navigate to the top of the window and select Slice > go to type and select Grid by Cell Size, this will prompt you to enter in the resolution of each frame in pixles. for me that was W:860px and H:700px.


Open up your spritesheet, select all frames and drag them into your scene, this will automatically cause unity to create an animation using those selected frames. Save this as anything you like, sticking to a naming convention that suits you, I am naming mine Player_run.


Now with your animation created you can delete the sprite that you had just placed in your scene, we will be attaching this sprite to your character. Click on your player, go to animator in your components tab and drag in your Player_run animation onto your animator, this will make it so your player has an animation, however if you press play, the player will not show. this is because you have not told unity what your player sprite looks like just yet. Go to Sprite Renderer in your components tab and the first option should be an option to select your sprite. click the round button beside this and search for your sprite and select it.

Now your player will show, and when start is pressed, you animation will trigger, but there has been no collision set yet so you will simply fall through the ground, since we are working with sprites here, go ahead and press Add Component and search for Box Collider 2D, add this into your player.