Help recreating a game in Godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By redstonecreeper8

I want to recreate the mobile game Spaceflight Simulator in godot. If you haven’t heard of it, I highly recommend you give it a try, it’s free and a small file size. Basically, it’s a simple 2D orbital mechanics simulator. So far, I have a Rigidbody rocket I can fly and an Area2d planet that acts as a gravity point. What I need help with is:

  • How I can make the planets orbit around the sun.
  • How I can display the current trajectory of your rocket
  • How I can deal with navigation (how to set up transfers and such)
    It really isn’t super important that I perfectly replicate the game or make it super realistic. I’m not actually looking to make a simulator, I just want to implement spaceflight in my sandbox game. Thanks in advance for any help!

Not answering to your problem but ask a question :
Do you try to detach some part of your rocket ?

Rem | 2022-12-08 13:34

:bust_in_silhouette: Reply From: Lopy

For orbiting planets :

  • First, get yourself a function, that puts the planet on the right spot based on a fraction (0-1, 0-360 or 0-2PI). For circles, you simply use cos, sin, and multiply by the distance. If you want proper orbits, they are elipses, with the sun as one of the focus points.
  • Then, use a Tween to call your function repeatedly, over the desired time and interval.

For your trajectory, either calculate it yourself, or just shoot little indicators, with the same physics as your spaceship.

For navigation, I have no clue what you mean by that. If it is camera movement related, then you will also want to use Tweens to make the movement more natural.