“Back to Square One” prototype made with Unity and LeanTween

If you liked the HTML5 prototype of “Back to Square One” I showed you last week, you will be happy to know I ported the code to Unity using C# and LeanTween.

What is LeanTween? Well, you should know Unity is awesome but it does not natively support tweens like Phaser does. Too good there are some interesting tween libraries in the asset store, most of them free, and after a quick overview I choosed LeanTween.

Apart from that, I tried to keep the code as similar to its Phaser counterpart as possible, I am just using another sprite as pivot point to rotate the square as with Unity you can’t change the registration point of a sprite at runtime. Actually, you can try some workaround but it’s a hassle. Guaranteed. It’s much easier to create a sprite as pivot point and attach the square to be rotated as child.

Have a look at what we are going to create:

Click on the stage to make the square roll and the terrain scroll. You will see two little red square. The one you see at the bottom right of the square is the pivot point, while the one you see as you start moving the square is the parent of all terrain tiles.

I am assuming you know how to create prefab, scripts and cameras in Unity, if you are in trouble check my Unity Flappy Bird prototype which explains all the basic concepts.

I placed all the code in one single class, so have a look at the code commented line by line:

That’s all at the moment, I plan to turn both this prototype and the Phaser prototype into two simple games, and at the moment you can download the complete project.