The PSD Importer is one of the best features for making 2D games. It saves a lot of time, because we are able to update the PSB file, and the updated sprite will be reflected in Unity immediately.
You can read more about the advantages of PSB Importer here.
But after setting up your characters, you may see this that some limbs from a further away characters are overlapping the front characters. This is because each limb is assigned to a sorting layer, and sorting layer is global. If the eyes are higher than the head, ALL the eyes will overlap ALL the heads.
You can see an example below.
The solution is very simple. Just apply Sorting Group to the parent gameobject or the main child gameobject.
And the limbs of your character will be grouped together. Unity is just awesome!
Finally, if you have setup your pivot properly, you just need to change some settings in Project settings, under Transparency Sort Axis.
To setup a 2D character, what we did, was to create an empty gameobject as the parent container for the sprites, animations, effects and other objects.
In theory, we will want to create a parent container. It should house the script and collider. And we should add an Animator components on the child to animate the all child gameobjects.
The concept is simple, if we put animator component on the parent object, it will clash with the movement script. So all animations should be affecting the child while the character can still be moved around.
But this is assuming we are making a side scrolling game that don’t allow the character to jump, or we “design” the game such that during a jump, the character is invincible, because the collider is turned off, while the shadow is still on the ground. This is another topic what we will cover at a later stage when we are coding the character behavior.
Next, we need to setup the pivot point of the Asset. We are making a side-scrolling game, so that we need to use the bottom centre of the character. Bottom centre is where we place the collider and the position of the characters, to follow correct overlapping of characters.
We do that by selecting the asset in Project tab, and select custom for pivot.
This is a simple setup for 2D characters, the same concept works for spritesheets. However, if you are using PSD importer, you will encounter some other issues. See issues here.
I feel that the Animation tool is very important for a 2D game, hence I tried 3 different tools – Spine, Anima2D and Unity’s new 2D Animation.
I started with Spine. Getting into the flow was easy since I had been using it for a while.
It is easy to export the animation for Unity. My opinion about Spine is that it is a very lightweight software, it loads fast, it’s easy to pick up, and the quality is out of this world. There are lots of Spine animators out there and it is not hard to find someone to help out with your games.
I tried using Anima2D because I read about some runtime issues for Spine. The animation data from Spine has to be exported to JSON to import into Unity. (Hmmm… isn’t it similar to other 3d software? Exporting to FBX with all the data?) Anyway, Anima2D is a great tool and it was very well integrated into Unity, I tried rigging a character and did a quick animation test, everything feels good. And I heard that the guy who developed the tool was hired by Unity. Check out the screen capture for rigging the tail.
And finally, I installed Unity’s 2D Animation package and explored around, and followed their online documentation. To my surprise, the tool worked very well for me. Even though it’s still a “preview” feature. Thanks to the talented team at Unity who are still catching bugs and improving the software while I’m writing this post. The tool is similar to Spine and Anima2D, and the development flow seems to be more integrated than Anima2D. You can check out how I set up the character’s sprite, bones and rig below.
After testing out the 3 different tools, I felt that there’s not much difference between Anima2D and Unity’s 2D Animation. Although Spine a more powerful tool and it’s easier to find animators who know how to use Spine, I decided to go with Unity’s native 2D Animation.
Reason being, I’m not a real programmer. I chose a native tool, so I have lesser things to troubleshoot when there are Game Engine upgrades. But these were just my personal opinions.
If you have any questions or feedback, feel free to send me an email. 🙂
In 2018, after much discussion with my wife, I decided to start developing games again. After considering different game engines, I took the leap to start learning Unity(again) after my last attempt in 2011. (Unity version 2.5?)
Compared to 2011, there are so much more resources available, and so many assets to speed up the game development.