How do I make an object enter and exit orbits?

Get help using Construct 2

» Sun Apr 05, 2015 8:34 pm

Hi,

I have two circles, the smaller circle of which revolves around the other bigger circle (simulating an orbit). When the user clicks with the mouse, there is an impulse applied to the small circle which jumps. I want that if the smaller circle lands back on the bigger circle, it goes back into orbit again and its speed and direction ( clockwise/anticlockwise) change depending on the point of impact. I am using the physics behavior but there are a lot of irregularities. Can someone suggest a way to do this? Many thanks.
B
5
Posts: 13
Reputation: 249

» Mon Apr 06, 2015 2:21 am

B
60
S
10
G
10
Posts: 1,013
Reputation: 9,145

» Mon Apr 06, 2015 12:20 pm

Hi,

This seems good when using the platform behavior but I don't want to use it as physics and platform behavior working together can cause some issues. Also, it seems a very unnecessary route to take. As of now on collision I am applying a force on the small ball towards the center of the bigger ball. I have disabled all physical properties of the bigger ball and the ball as of now stays in motion depending on how it lands. But Its still not clean. I will work on it and post some better results if I can find it. It should be very simple but I seem to be missing something
B
5
Posts: 13
Reputation: 249

» Mon Apr 06, 2015 6:04 pm

For orbits with physics you can do it using equations of actual orbiting. Some info and capx on it here:
how-do-i-set-up-an-span-class-posthilit-orbit-span-using-span-class_p855815?#p855815

Basically you can do the gravity force with "newton's law of universal gravitation" and set the orbit by setting the velocity to a calculated "mean orbital speed" and set the direction to be perpendicular to the direction from the moon to the planet.

Calculating the impulse to change directions may be doable, just your standard algebra problem, but it's probably simpler to just set the velocity directly.
B
82
S
26
G
62
Posts: 4,824
Reputation: 45,188

» Sun Apr 12, 2015 6:28 pm

Thank you. Wouldn't this be too heavy on memory? considering it updates forces every tick and in case of of multiple objects wouldn't it get too high?
B
5
Posts: 13
Reputation: 249

» Sun Apr 12, 2015 6:56 pm

You mean heavy on cpu usage? Test it and see how heavy it is. Setting the force is basically just setting a number and has a negligible performance impact.
B
82
S
26
G
62
Posts: 4,824
Reputation: 45,188