Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
November 26, 2014
arrowPress Releases
November 26, 2014
PR Newswire
View All
View All     Submit Event






If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 
Stuff I've learned about making spritesheets work in Unity.
by Jeff Postma on 12/06/13 02:32:00 am

2 comments Share on Twitter Share on Facebook    RSS

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

 

I've finally been able to put in some time playing around with the Unity 4.3 beta and getting a grip on animating things. It's not as intuitive as I thought it would be, but once you go through it once or twice you start to realize how things work.

If you have a spritesheet click and drag to add it to Unity.
In the inspector set the texture type to Sprite. The Sprite Mode dropdown can be used to know if the file should be split up or kept whole. In this case I'll choose manual to split the sheet into different individual images.
 

In the Inspector choose sprite, then manual and click apply.

After applying these settings the Sprite editor can be opened.
The Sprite Editor allows you to choose sprites from the sheet. Clicking the Slice button opens a menu to have it Auto select the sprites from the sheet. If the transparency is coming in correctly it can work pretty well and get rectangles around the sprites pretty easily. In this case I have to manually select them since the purple background is there. I recommend setting up your sheets properly to have transparency.

Selecting each frame of animation from the sprite sheet. Applying splits them into multiple assets.

I named each square up1, up2, right1, right2, etc. After you have selected them, named them, and trimmed them if necessary, click Apply in the upper right of the Sprite Editor. This will split them up into individual assets for you. I believe it still keeps them stored in the big sheet for better performance.

To create an animation, select several of these individual assets together with a shift or ctrl + click and then click and drag the selection into the scene editor. You'll be prompted to save a new Animation and a new Animation Controller.

Open the Animation window if it's not already open. Here you can edit the animation by dragging and dropping various assets into the timeline. Or you can create new ones and keyframes (I haven't researched or played with keyframes much). Another option is to click the record button (that looks like a circle). This records any actions you make in the scene view. So if you have multiple objects making up a player you can move them or rotate them and record step by step to make frames of animation.

Creating the walking right animation.

Adjustments can be made to the time between each frame and the amount of time each frame is shown. I then placed the animation as a child object of the player object. Hit play and it should animate.

In just a few more steps of adding RigidBody2D and BoxCollider2D components you have a character than can interact with the world. You might want to put something with another BoxCollider2D underneath him. Now we just need to add a script to allow movement based on input. I think I'll save that for next post.

Animation and Physics.

I'll keep plugging away trying things out and learning how to do this. Hopefully I can get a lot faster and start actually releasing some projects. I've been enjoying lots of games lately too like Tomb Raider, Kingdom Hearts, Tales of Xillia, and Zelda Wind Waker HD.

Happy Halloween!
 


Related Jobs

Obsidian Entertainment
Obsidian Entertainment — Irvine, California, United States
[11.25.14]

Engine Programmer
Obsidian Entertainment
Obsidian Entertainment — Irvine, California, United States
[11.25.14]

Gameplay Programmer
Obsidian Entertainment
Obsidian Entertainment — Irvine, California, United States
[11.25.14]

Server Programmer
Avalanche Studios
Avalanche Studios — New York, New York, United States
[11.25.14]

Vehicle Designer





Loading Comments

loader image