#Planet Orbits

1 messages · Page 1 of 1 (latest)

drifting zodiac
#

This is probably happening, it’s velocity moves it to a position outside of orbit

#

@hallow trout

#

I did attempt Simferoce’s idea, since it also works out mathematically but it has the opposite problem where the planet actually starts moving towards the sun.

#

I could’ve did something incorrectly since I was in a rush, but my guess was that it created a velocity that moved the object inside the orbit

drifting zodiac
#

The only ideas i have are to either

Vector2 dir = (sun.pos - planet.pos);
planet.position = dir.normalized * fixedDistance;```
#

Actually you might also be able to do some fancier math that creates a vector to move the planet to a point on the orbit by the next physics timestep.

drifting zodiac
#
Vector2 dirToMove = new Vector2(5,0);
rb2d.velocity = (dirToMove.x/Time.fixedDeltaTime, dirToMove.y/Time.fixedDeltaTime);```
This should cause the rb to move at 5 units per **frame**. If you can calculate the next point on the circle to move to, you can generate a direction to that and the rb should in theory be at the position on the next frame
hallow trout
drifting zodiac
#

by far the easiest solution, hopefully that’s enough 🙏

hallow trout
drifting zodiac
#

instead of generating a velocity to a point off the circle

hallow trout
drifting zodiac
#

good luck on your project! 🍀

hallow trout
#

Thank you!

hallow trout