Published in


Tip of the Day: Putting Life in Sprite in Unity2D

Unity 2D engine uses sprites that are applied on gameObject to give them shapes textures. Normally a sprite is a simple graphical image that does not move.

Series of sprite in a sprite

In order to animate a sprite, you need to create a sprite sheet. A sprite sheet is basically an image that contains several smaller images where each image is basically a frame in the animation. Combining these images using Unity Animation allows the character or object to animate.

So how would you animate or more these sprites?

A. Select your sprite sheet, and make sure the texture type is set to Sprite(2d & UI), then enter the sprite editor. In the editor, you can either slice each image manually or let unity to slice it automatically.

B. Open the animation window, select the gameObject you want to animate and make sure you attach to it the Sprite Renderer, and then click create animation in the animation window.

C. It is as simple as dragging and dropping the sprites that you sliced from the sprite sheet into the animation window and adjusting their speed.

Drag and drop Animation

D. Without getting into too much detail now, after creating the animation, Unity will create an Animator controller that will be a component on the parent object. Open the animator window, and there you adjust the conditions when your animations will play. Here is an example:

You can set parameters for each animation transition that is controlled through code

The Unity animation system is very friendly and easy to use, and with enough practice you can do many amazing things with it.




Everything connected with Tech & Code. Follow to join our 900K+ monthly readers

Recommended from Medium

When you type ls -l *.

Hyper Terminal plugins that will make your life easier

San Diego ServiceMeshCon 2019 Presentation Notes and Summary: Morning Sessions

The Story Of A Subject And An Observer: The Strategy Pattern.

Observer Pattern

Unity Feature 101: Basic Saving Using PlayerPrefs

Industry use cases of Jenkins

Keyboard shortcut: how to search through all files and find matches in IntelliJ IDEA

Midterm: Lighthouse

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mohamed Hijazi

Mohamed Hijazi

A knowledge seeking biologist who is following his passion into a full time career in Unity / Game Development.

More from Medium

Building a Modular Ducking System

Use LINQ in UNITY Games

Switch Statements to the Rescue

Variables -The building blocks of programming.