Development Update #11 - A New Perspective with Unity

Hi, my name is Pete Smith and I’ve taken over the development of 2112TD.  Over the coming months I will be blogging about the creation of the game in Unity.  Today I’ll be telling you a bit about how the levels use both 2D and 3D components of the game engine. 2112TD has hundreds of megabytes of beautifully rendered worlds and creatures.  The player views the action from an elevated but fixed perspective:
 


 

The scenes have a real feeling of depth, however in reality everything is built from 2D images.

How could I compose this world in Unity:  2D or not 2D?  

  • 2D: All objects are constrained to a flat plane facing the camera, or
  • 3D: Key objects are correctly spatially placed in 3D

 I decided to go the 3D route, for two main reasons:

  • It gives future flexibility to use 3D effects such as particle collisions and projectile motion
  • The movement of objects would be sure to look realistic

To make this work I created an invisible base at a 33 degree angle, corresponding to the perspective of the artwork. Then I placed towers, enemies and the enemies’ paths on this base. The local y axis of this plane (green arrow in screenshot below) could then be used as my world up axis, around which I could calculate rotations:
 


 

This obviously looks rather strange.  However using an orthographic camera, enabled by turning on Unity’s “2D” mode, things fit into place perfectly from the player’s perspective:
 


 

All collisions and triggers can then take place in 3D space.  For example, an enemy coming into the range of a tower is detected via the overlap of two spherical colliders.  This is demonstrated in the following video:

I hope you found this interesting.  Next time I’ll be talking about how the tower animations are put together.