How do I make an object orbit?

Get help using Construct 2

Post » Sun Jul 07, 2013 12:41 pm

My object void sucks other objects. These objects need to be absorbed and when they get too close, the object orbits around the void and then goes inside the void then getting destroyed. How do I do this?
B
4
Posts: 11
Reputation: 247

Post » Sun Jul 07, 2013 1:17 pm

This should give you a good starting point;

http://www.scirra.com/forum/how-do-i-make-earth-rotate-around-the-sun_topic45633.html

Then every time the object makes a full orbit, or x amount of time has passed, slowly decrease the distance until it collides with the object.

I think you'd need to use delta timing to decrease the orbit, but if you store that rate in a variable, you'd also be able to increase the rate the object gets sucked in the closer it gets to the object it's orbiting. Which would make for a much better gravity effect.

You could create a circle "gravity field" object and turn off its visibility, and use that to detect when an object has fallen into the object's gravity well. I think you'd need to pin the gravity field to the object you want to have gravity, and then resize it based on the mass of the object.

Once your object collides with the gravity field, that's where you'd start the orbit away from the centre of your larger object, so you'll need to calculate the distance between the small object, and the centre of the larger object, and make that the point that the object starts orbiting.

Hope that gives you some general direction.Nullus2013-07-07 13:27:27
B
3
Posts: 23
Reputation: 221

Post » Sun Jul 07, 2013 3:00 pm

This isn't pretty, but here's a variation with spiral. You just need to juggle the numbers to change the rate(s).

SpiralTest.capx
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,677

Post » Mon Jun 09, 2014 2:17 pm

really interesting spiral idea. I was looking for something similar to this
B
103
S
40
G
23
Posts: 394
Reputation: 20,537


Return to How do I....?

Who is online

Users browsing this forum: Aergo, AllanR, anty21ro, Ethan, Fenix18, Iftikhar555 and 11 guests