- Home /
How to move rigidbody relative to a moving object?
I have a solar system and a spaceship. The planets are moving in circles around a central point. The player controls the spaceship by adding forces to its Rigidbody2D. If a player gets close to a planet, I would like to attach the spaceship to the planet, so the planets' movement gets applied to the player and the player only have to move relative to the planet. I tried adding the planet's position change every frame to the player position, tried adding forces to the player rigidbody, tried parenting it to the planet, tried joints, but nothing works. I always get jittery movement with sudden jumps or nothing at all. How should I properly attach the player to the planet so it moves with it?
Problem: https://www.youtube.com/watch?v=g5mEkt5_dDI Planet vector: https://www.youtube.com/watch?v=ES9x7lPcAKE