0
\$\begingroup\$

I have a monster (boss) that spawns a minion (m1) which orbits the boss. m1 can spawn its own minion (m2) which orbits m1. This creates a situation where m2 is orbiting m1 and m1 is orbiting the boss.

This results in m2 having an elliptical orbit. I'm wondering if there is some way to make it such that m2s orbit is always circular just like how m1 orbits the boss.

the orbital movement calculation is done as such, and each frame the monsters are updated about where their origin is (ex, m2 knows each frame where m1 is, and that is assigned as m2's origin to revolve about):

position.x = origin.x + radius * std::cos(angle);
position.y = origin.y + radius * std::sin(angle);

if anyone has any ideas, please share. thanks. I feel like this is impossible but figured I'd ask anyways.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You can get m2 to trace a circular orbit if its orbital period exactly matches m1's, and it orbits in the same direction (clockwise / counter-clockwise). It will orbit m1 once for every time m1 orbits the boss.

The downside is that this won't look like so much like an orbit from an outside point of view. For example, if the orbital phase of m2 exactly matches, or is exactly 180° offset from m1's, then it will look like m1 and m2 are both skewered on one rotating bar extending from the boss.

Desmos graph of orbits

Here's a Desmos graph you can play with. The blue line represents the orbit of m1 at a radius of 5, and the red line is the orbit of m2, at a radius of 1 from m1. The parameter p controls the phase shift - how far ahead or behind in its orbit m2 should be, compared to m1.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .