I have a rocket ship flying into space in a 2D (3D art) side-scrolling game. My question is, assuming the gravity within the project settings is necessary to the gameplay, how do I create isolated gravitational fields with limited range?
For example, if I'm flying my rocket against the gravity pulling down, I also want to encounter planetoids that pull me in if I get too close. It must be created within the physics system because the rocket needs to be able to resist it (or even land on the planetoid).
I am no expert by any means, but my first thought would be to have a sphere with sphere collider that would represent the reach of the gravitational pull. set the collider to be a trigger. Then you would need a script on the object that is going to be acted upon by the gravity that would register that it is in range to be under the gravitational pull and then calculate the distance from the planet to work out how much gravity should be applied. This is where I would start, but that doesn't necessarily mean that it would be the best way.
To add to that, the way I would apply the gravity in the script would probably be to alter the rotation and transforms, so every second the ship should be moved some amount closer, or something along those lines.