Sprite Animation

Now, with the new sprite system I would like to know how to cycle through all the sprites in a texture.

So, I have a character with a walking animation and they’re staying on the exact same frame, how can I change the current texture?

You need your sprites put into one image file. So, for me, I used photoshop to make many sprites. Then I pasted the sprites all into a 1024x1024 sheet. I then imported the file by selecting ‘multiple’ instead of single for sprite mode.

Once you have your sprite atlas in Unity. In the import panel, set the sprite mode to multiple and select sprite editor. Drag boxes around your sprites. The trick is to remember that despite the shape of the sprite it will fit into a box shape in the atlas so be careful to not overlap your sprites. In photoshop I line up the sprite so it is adjacent to another sprites pixels and then I hold Shift and move the sprite on a straight axis until it fits into the position I want.

In the sprite editor of the import panel, once you have setup the different boxes around each of your sprites on your ‘sprite atlas’ click apply in the top right of the sprite editor and close it or move it out of the way.
You will not lose any data by closing it.

Next you will see in the project panel that your sprite now has an arrow you can expand to reveal all the boxes that you made in the sprite editor. These boxes will contain your sprites.

Ok, now to answer your question. Open the animation panel. Select your object in the Hierarchy that you want to animate. Perhaps the animation panel is empty? No problem. Where it says ‘sample’ to the left of that you will see a horizontal rectangle that can either contain the name of an animation clip OR it can be blank. Click on that and select “create new clip”

Once you have selected the clip you will animate in, click the record button (red circle).
Once it is in record mode and the ‘play game’ buttons are now red you will be able to see the time slider. Move the time slider to the time you want and select any object in the hierarchy that you want to animate or change the sprite.

Once you have selected the object, go to your project panel and select the sprite atlas that you created. Drag one of the sub-components (one of the boxes in the list of boxes that you created in the sprite editor) into the timeline on the animation panel.

The object you selected in the Hierarchy to edit animation for will now change it’s sprite to the sprite you dragged in at that point in the timeline.

If you need more help, let me know. I’m pretty advanced with this however I have a problem where the 2D sprite’s movement is only animating on world axis instead of local axis.

PS: If you want a clean transition from one sprite to the next, you will need to select the keyframes in the animation panel and right click on them and select ‘both tangents’ and select ‘constant’. This will also set the curve type to ‘broken’ which is good if you do not want crazy transitions for your sprite sheet. Sometimes these transitions are good but sometimes they are not the desired result. I use a mix of both.
For example, I have a character with legs and arms that are hand-drawn animation and I like broken curves with constant transitions but for some accessories on the character I use smooth animation by using smooth curve transitions to rotate them. But if I use smooth transition for the hand drawn animation the result looks very retarded.

PS: Hot Tip! Animation to the X,Y,Z transform.position will be in world axis regardless of having a parent object. I don’t know of anyway to overcome this other than to code an animation however you can get some effects by using 2DTK and using attach points to control the position of objects on certain frames.

UPDATE:
Since 4.3 the animation has been fixed. My turrets etc will recoil back on the local axis and the alien’s head animates side to side instead of north to south.

Check this video