Escape From a Moon: Creating a Rotating 2D Platformer in Unity (1) | GitHub

It’s been some time since Ludum Dare 38 and I wanted to make some improvements to my Compo entry, called Escape From A Moon (you can take a look at Ludum Dare rules if you don’t know what I am talking about), so I worked on them and not long ago I released Escape From A Moon v0.2. You can find the devlog here. Now that this new version is out, I have decided it is time for me to explain a little bit about how this small prototype game works.

You might think this is a fairly simple game and there is not much to explain. Well, that’s basically true 😀 but it’s also true that developing a platformer with a rotating environment can be challenging and is much more difficult than a “normal” one. I will explain this later, but first of all I want to clarify: I am not saying this is something new or revolutionary, and I didn’t look for examples of what I wanted to achieve either, so there may be better approaches than the techniques I’m going to share here, but I want to share them anyway. I will split the explanation into several posts, so this first post will only contain the basics.

Just one more thing: let me remind you all this is an open source project so you can download the source code, use it, and collaborate on it if you want. Now let’s start.


 A circular environment

This is the whole environment of the game

Inspired by the LD38 theme (Small World) and with not much originality, Escape From A Moon takes place in a very small satellite. The player controls an astronaut who needs to walk and jump around in order to reach his spaceship before he runs out of oxygen. A peak prevents the astronaut from taking the short way, forcing him to encompass the whole satellite.

The rotation in Escape From A Moon is real. This is: it’s not a visual trick by which I am rotating the background instead of moving the character. I didn’t do such thing because I don’t think physics would work properly, it would have limited extensibility (what if I wanted to add the ability to move to a different satellite or planet?) and the result would have been much less intuitive from the development perspective. But, making the character walk around the satellite has some important implications. Let’s go through all of them.


#1 Vertical orientation

For the character, the vertical orientation depends on the position on the planet. Which means, the vertical orientation can be constantly changing. Knowing the vertical orientation is important for things like jumping: a jump is basically the result of applying a force in the direction of the character’s vertical orientation.

Vertical orientation is defined by the vector that goes from the center of the planet to the character’s position

To get the vertical orientation vector, just subtract its origin (planet’s center) from its tip (character’s position). So, in the Character script:

Vector3 _direction = transform.position - planet.transform.position;
upDirection = new Vector2 (_direction.x, _direction.y).normalized;

In this case, we are also storing its normalized, 2D version, as we will need it later.


#2 Horizontal movement

Intuitively, we can think of horizontal movement as the one that is parallel to the ground (assuming the ground is horizontal), or perpendicular to our vertical orientation. But in a circular environment, both the vertical orientation of the character and the ground’s orientation depend on the position within that environment. So, in order to know in which direction to move the character, we need to calculate it.

As mentioned above, the horizontal direction is perpendicular to the vertical one. Given we have already calculated the vertical direction vector, we can get the horizontal direction from it.

Looking at the character with a 3D perspective, we can see the trick. The red arrow is the vertical direction. The blue arrow is the depth direction, which is fixed. The green arrow is the direction we want to calculate.

As you can see in the image, we already have two direction vectors: the vertical and the depth ones. The horizontal vector is perpendicular to them both, so we can get it by calculating their cross product. Leveraging the _direction vector we got earlier:

Vector3 _walkVector = Vector3.Cross (Vector3.back, _direction).normalized;
Vector2 _walkDirection = new Vector2 (_walkVector.x, _walkVector.y);



We have seen here how by applying simple vector arithmetics we can get the information we lack because of the nature of the game. Now we have both the direction in which to apply the jump force, and the direction in which to apply the walk force. More on this, in a future post.

Countless v2.0: a big update


App Store EnGoogle Play En

Press Kit


Over 5 months after the first release of Countless, a big update, the version 2.0, is available. This new version features lots of additions and improvements:

  • Use shields to protect you against mistakes
  • Collect coins to buy shields and skins
  • Multiple different skins to unlock
  • Fully revised difficulty curve
  • Improved touch response: now you can touch two pieces at the same time
  • Ads are now less annoying and give more rewards
  • Many visual improvements
  • By popular demand, now you can leave the name empty when you make a new record

Countless was born as a simple project with the idea of learning how to use Unity game engine, as well as being able to release a game in a short period of time. There were no plans to expand it very much, and I only planned to maintain it by fixing issues from time to time while I was working on a new project. But once I saw the game actually released and received feedback, I decided I needed to do some important changes, and here they are. Let’s take a detailed look into some of them.

Difficulty Curve

The original difficulty curve was very abrupt. It rapidly reached the most difficult point and stayed there for the rest of the game.

Here you can see how after just a few seconds, the board passes from 2x2 to 4x4 and the time per level is decreased to the minimum
Here you can see how after just a few seconds, the board passes from 2×2 to 4×4 and the time per level is decreased

In order to get a friendlier, more progressive difficulty curve, and at the same time offer a more challenging gameplay to those who manage to reach advanced levels, the progress in the game has been meticulously adjusted.

With the new, adjusted difficulty curve, the board increases its complexity in a much smoother way


The game now allows you to collect two different item types: coins and shields. You can get coins in multiple ways (playing, viewing ads, and even as a gift!). With them, you will be able to buy shields and unlock skins or themes that change the colours in the game. Use the shields when playing to protect you against failures!

Everyday you will get a gift when opening the game


See the icon at the bottom left corner? Touch it to open the shop!


In the shop you will be able to buy stuff using the coins you have earned. You can also get free coins after watching an ad!

Visual Improvements

Many small visual improvements have taken place: more icons and less text, more color variety, and other improvements to make everything more clear.

Some new icons have replaced the old text markers, and a small separation between pieces in 2×2 boards has been added to improve the look and feel


With the new themes you can switch the color scheme to a different one if you have unlocked it


New colours have been added to support the new 5×5 boards as well


Hopefully this update will make the game much more fun and engaging. Are you enjoying it? Do you have anything to suggest or comment? Please leave a comment at the bottom of this post or use the Contact Form.

See you in the leaderboards!

Countless, my new game



And here it is. Or almost 🙂 . After some months spending part of my very limited spare time learning how to use Unity and working on a game, it is almost finished. Let me introduce Countless.




Countless is a very simple game. The player is presented with a square board full of squares. Each square has a number, and the player must match numbers, in correct order, as quick as possible. The player will fail when not matching the next pair of squares in time. The goal? Match as many pairs as you can.




Despite of its simplicity, developing Countless has been (and is being) very didactic when it comes to using Unity game engine. It involves a lot of animations, data persistence, scene and object management, event handling, UI configuration, ads, and access to some target systems’ features. And a lot of scripting. This is my first experience using a third-party game engine. My previous game, EggOrama, was developed from scratch using my own engine.




For me, Countless serves a dual purpose. On one hand, it is a game that I will publish. It will be free, but include some ads (as well as a little gamification of this). On the other hand, by working on it I have been able to learn a lot about the game engine without having to spend too much time on each feature. After releasing this game, I will be prepared to start another one (but won’t forget updates for Countless as well).


Countless will be released soon, for iOS and Android, featuring both local and online leaderboards. More platforms could eventually join the party. No specific release date yet, though!





Countless, mi nuevo juego


Y aquí está. O casi 🙂 . Tras algunos meses pasando parte de mi muy limitado tiempo libre aprendiendo cómo usar Unity y trabajando en un juego, está casi terminado. Permitidme presentaros Countless.




Countless es un juego muy simple. Ante el jugador se muestra un tablero cuadrado lleno de cuadrados. Cada cuadrado tiene un número, y el jugador debe emparejarlos, en el orden correcto, tan rápido como sea posible. El jugador fallará cuando no empareje el siguiente par de cuadrados a tiempo. ¿El objetivo? Hacer tantas parejas como puedas.




A pesar de su simplicidad, desarrollar Countless ha sido (y está siendo) muy didáctico en lo que a usar el motor Unity se refiere. Involucra un montón de animaciones, persistencia de datos, gestión de escenas y objetos, configuración de UI, publicidad, y acceso a algunas características de los sistemas de destino. Y mucho scripting. Esta es mi primera experiencia usando un motor de juego de terceros. Mi anterior juego, EggOrama, se desarrolló desde cero usando mi propio motor.




Para mí, Countless sirve para un doble propósito. Por un lado, es un juego que voy a publicar. Será gratuito, pero incluirá algo de publicidad (así como un poco de gamificación de esta). Por otro lado, al trabajar en él he podido aprender mucho sobre el motor sin tener que pasar demasiado tiempo en cada característica. Tras publicar este juego, estaré preparado para empezar otro (sin olvidarme de las actualizaciones para Countless).


Countless será publicado pronto, para iOS y Android, e incluirá tablas de clasificación tanto local como online. Puede que más plataformas se unan a la fiesta en el futuro. ¡Pero no tengo una fecha de lanzamiento específica todavía!