Skip to content

Devlog #2 - Gravity

Orbit

Last time, I left you on a cliffhanger, saying I'll probably work on Planets.

Well I indeed worked on that. We are going for a game that takes place in space, so I need a solar system. There's lot of ways to do this, with Physics, General Math Equations (Kepler) or simple Rotation.

A while ago, I already did that for a small VR project, basically the idea was to create a RTS game where you see the galaxy and move your units with VR Controls. I was correct and I managed to do some of the features I needed (at that time, I used Kepler stuff to have all kinds of orbits).

But this game should be really simple and performant, so we are going with very basic Rotation helpers to get Circle orbits for our systems.

Here's my debug scene with a Sun, a Planet, and a Moon.

Orbit

So definitely a simple setup, with a few params:

  • rotation_speed: Self rotation speed
  • orbit_speed: Orbit speed around target
  • distance: Distance from target

Later, I should be able to use those values to compute some data for planets:

  • The Day/Night cycle for the planet with rotation_speed
  • The Temperature, that will help with creating seasons with rotation_speed, orbit_speed and distance

Of course, with those values, I should be able to decide what type of Fauna and Flora the planet has, so that the player can decide if he wants to explore, and create an Outpost or not.

Planet

Gravity in a game is either easy, or complex. In quite a lot of games, defaults are great (9.81g along -Y axis), but when you want to have planets that all may have different gravities applied to the player, it's a bit more complex.

Applying gravity is not the worst, but you need to think about Controls and Camera after that.

With a lot of help on the web to do that with godot (There's a lot of tutorials for Unity and Unreal Engine, but there's less for Godot), I have something I like for now, that works for my default character.

Here's a preview of the character walking on a small sphere, while keeping the ability to Jump, and the particles when he is Grounded.

Planet

Of course, you'll need to trust me the sphere is not rotating, but the character is properly moving 😉

I'm happy with the result, and know what's going to be my next development:

  • Adding social stuff to this Devlog
  • Trying to build a small starship to navigate between planets