Skip to main content


Showing posts from April, 2013

Creating 2D Animation For A Side Scroller In Unity3D

Update 3-13-14
Unity kinda released some really nice 2D tools, I really don't know how relevant or helpful this is now.

I've been working on a 2D side scroller. Being my cheap self I'm not going to bother buying some helpful tool that would probably speed up everything a substantial amount, and created my own method of 2D animation for things in Unity3D. This code does not work with a sprite sheet, but I hope it makes it easy enough for you to incorporate one if you wanted to.

 The animation is displayed by updating the meshes material's texture each frame (this can mess up at high frame speeds).
This code is assuming the 2D sprites are moving along the X and Y axis.
When changing directions, it is scaling the transform negatively across it's x axis.
Its assuming default direction facing is right.

using UnityEngine; using System.Collections; public enum Directions{left,right} public class FlatCharacterAnimation : MonoBehaviour { …