Hello, I'm brand new to godot, and Im working on a 2D space game. I've gone through the docs and set up a spaceship which I can fly and a planet. I have two questions, one easy and one complicated
Easy question: How do I apply_impulse relative to the ships rotation? i.e. when I thrust I want the ship to go the direction it's pointing. Right now it uses some dumb trig I did, so it works fine, but Im sure "local axes" are built into godot somehow.
Here's my gravity code (runs in integrateforces under the ship):
(Basically, I get the distance to the planet, get a normalized vector thats points towards the planet, multiply/account for the inverse square rule, and apply an impulse with that vector)
My problem is this: I want to write a function that puts the ship in a perfect circular orbit (not with the thrusters - just magically, for when the scene starts). Google tells me that orbital speed is . Here's the function so far:
var magnitude=sqrt( (G*(get_mass()+planet_mass))/distance )
(You'll notice that this doesn't take into account where the ship is around the planet - i.e. the angle - so right now this only works when the angle from the ship the the planet is 0 - so on the left or on the right, in line with the planet. I'm testing with the ship directly to the left of the planet, so this can't be the problem)
For some reason, this velocity is way too slow, and the ship hits the planet. Any idea why?