Notifications
Article
Gravity Voyager: Game Design
Published 2 years ago
130
0
How the Inspiration Got, Physics Model Designed, And More!
It has been several months since my game Gravity Voyager  released in App Store. Gravity Voyager. In Gravity Voyager, you should drive your spaceship traveling the space while avoid being pulled into stars by their gravity. Today I gonna to share something about the game design of Gravity Voyager at here.
 
Idea
 
So firstly, you may wonder how the idea of Gravity Voyager  came from? The idea of Gravity Voyager is originated from the course design of Introduction to Game Design in my university (I majored in Digital Media Art at my university).  The idea is simple but elegant: Reach the goal, avoid being pulled into stars or black holes. And as the position varies, strength and direction of gravitational force change too. If your spaceship near a star, you can feel a strong force trying pulling your spaceship into the star and vice visa. If your spaceship lies between two stars, you may not feel there is whether a force because the gravity of two stars cancels each other. Stars can rotate around other star or even form a double star system. You can see, the basic idea is simple enough, but it can generate a lot of interesting details.
 
No idea comes from vacuum. The idea of this game is inspired by…. an iPhone game called Labyrinth, a game that you control a steel ball by tilting a wooden labyrinth (using iPhone built-in accelerometer to control). This game is very popular during 2008-2009. I have played this game on my iPod touch and it is very addictive. In Labyrinth, you should keep the steel ball from falling into holes. So I wondering how about add something like “gravity” to these holes? This is how the basic game idea originated.
 
Actually, I have made a simple early prototype using Unity while finished the course design, you can clearly see the influence of Labyrinth:
 
Physics
 
The core concept of Gravity Voyager is of course “Gravity”. Recall what we learned during senior high school, the formula of Newton’s law of universal gravitation is F = GMm / r^2, i.e. the force between two objects is proportional to the product of two masses and inversely proportional to the square of the distance between them. This is really easy to implement in Unity game engine using built-in PhyX system via scripting. In the formula, the factor G is the gravitational constant and we can simply assign it with 1.0 for convenience. The distance between the spaceship and a star can get through subtracting two position vectors and get the length of it.
 
However if we use this physics model directly, there is a noticeable problem: If our spaceship is not close enough to a star you hardly feel any gravity but in contrast, if your spaceship near a star you may not possible to escape from the gravity field of the star since the intensity of gravity is two strong where near a star. So I made a modification: rather than using the inverse square of the distance, I use the inverse of the distance. So the final formula using in this game is F = M * m / r. In each physics loop of the game, it calculates the sum of all gravitational force between spaceship and stars and applies to the spaceship.
 
(You may wonder how objects behaves if gravitational force between two objects is proportional to the inverse of the distance, rather than inverse of square of the distance. This is quite interesting. In this circumstance, the second cosmic velocity of any star is INFINITY, since the integral of gravitational potential not converge while distance approach to infinity. That means a spaceship can not escape the gravitational accretion of a massive body, whatever how great the launch velocity of. A good explain of this problem: https://www.zhihu.com/question/26941982)
 
The spaceship in this game is controlled via dynamic system rather than kinematic. In another word, it controlled by forces applied to the spaceship. You controlling  your spaceship flying to the right means game engine apply a force toward to the right to the spaceship. Turning and decelerating mean applies a force which the direction differ from the velocity vector. In the early game prototypes, there is no limit of spaceship’s speed. You can accelerate your spaceship to infinity if the scene is large enough. However, several problems occurred. It is hard to turn and decelerate while the speed is quite high. And while I did a play test, I find some player just accelerate the spaceship to a high speed to rush into the goal. So I add a drag force later. Drag is proportional to spaceship’s current speed, toward the opposite direction of current velocity. Suddenly it is much easier to control and prevent the player from cheating via “rush” tactic. It becomes a huge improvement of game design.
 
Stars and Star Systems
 
Another concept is stars. There are 6 types of stars. Each type of star has different size and mass. Stars are the main obstacle in the game. You can not let your spaceship being pulled into a star. But sometimes stars can be your good friend. For example, you can use the gravity of a star to accelerate your spaceship during a short time to pass another star easily. 
 
Each level has a unique formation of stars. Strength and direction of gravity vary in a scene so while a player playing the game, she/he should always keep focusing on the movement of the spaceship. A star can cancel another’s gravity, that allows me to carefully make a “tunnel” in many stars, that simplified a level while adding some complexity, kill two birds with one stone.
 
Naturally, stars can form star system. A star can spin around another star. Of course, multiple stars can rotate around one another star. Two stars can even rotate around each other (barycenter). A star system can be a parent of another star system. While a star is in motion, gravitational field changes too. That make the game more interesting and challenging.
 
According to Kepler’s law, the orbit of a star is a cone section: ellipse, parabola, hyperbola. In this game, we only consider the close form: ellipse. While a star spins around another, the orbit is an ellipse and the barycentre is the focus point of this ellipse. The speed is higher while it is close to the focus point and vice visa. I modelled this behaviour using kinetic method, via parametric form of ellipse (x = a * cos(t), y = b * sin(t)). The speed spin around is the inverse of the distance between two stars. It is not physically accurate but it works and using much fewer CPU cycles than using the dynamic model.
 
There is a special type of star: black holes. When I making black holes, I faced a tough decision of how it look like. Should it distort starry background or just appear nothing? Finally, I decide it should have no appearance. It may boring, but add the complexity: you can not find it directly, you can only “feel” it. So I add black holes in last 10 levels.
 
Scene Boundary
 
Scenes in every game should have a boundary, whether it is explicitly or implicitly. In early prototype you can see above, the scene has a clear solid boundary that can bounce off. But lately I changed to this, using red grid indicate there is the boundary.
The player can not across the boundary or she can be penalised restart the game. The purpose of this is to make game more challenge and also natural: because there is not a solid boundary in the space.
 
Control Schemes
 
As I said before, Gravity Voyager  is inspired by Labyrinth. In the early prototypes, the player can only control spaceship by tilting their device, like Labyrinth. Later I wondering how about let player can control via virtual joystick? It proved is much better than the accelerometer. Using the virtual joystick, the player can control spaceship more precisely and don’t look silly while playing in public places. So I made it default but player have the option choosing control spaceship via accelerometer in Game Setting interface.
 
Record Timer
 
 
Once you finished a level, the game saves your best record of length your take. The next time you play this level, you will see the bar above indicate your record. That let player trying beating their record and also give the player a pressure, make this game more interesting.
 
Collecting Stars
 
Once after finished a playtest, a player told me whether should add something else, such as let player collecting stars. I accept this advice and the result is unexpected good. It add another dimension to the game, while player trying to reach the goal, she should also have an option whether collecting stars. If she collects a star, she may not finish the level. So this change made the game more challenging.
 
Level Design in Unity Editor
 
In order to design level more effetely, I made some custom gizmos attach to the game objects. As you can see above, there are:
 
  1. Indicator of the level boundary.
  2. The orbits (purple circles)
  3. Intensity of gravity of stars (blue circles)
  4. Gravity field indicator (red lines)
You may noticed there is a white cross in the scene:
 
 
This is an indicator of ellipse orbit. The long and short lines represent the major and minor axis of the ellipse orbit. In Inspector, the values named A and B are the lengths of the major and minor axis. 
 
That’s all, thank you for reading! If you are interested in visual design of Gravity Voyager, you can also check my previous article:https://madewith.unity.com/stories/gravity-voyager-making-of-starry-background-and-node-based-image-compositing
ZB
Zhang Bo-ning
3
Comments