Start elliptical orbit at different points

Get help using Construct 2

Post » Sun Feb 09, 2014 5:35 pm

Hi there,

I've got multiple objects orbiting around my player in elliptical orbits, using info from the thread below.

http://www.scirra.com/forum/solvedtilted-ellipse-orbiting-movement_topic64560.html

To add variety, and so all those objects aren't tracing the same path and covering up each other, I've used random ranges for x, y and orbiting angle to vary the paths (by implementing them as instance variables). This has worked very well, but if I collect several of these objects in quick succession then they all tend to bunch up in corners together.

Is there a way of getting them to start in different places so that this doesn't happen? Failing that, how would I introduce a speed variable so that they spread out? At the moment the position is linked to time, and I'm not sure how to implement a constant speed variable.

Thanks.
B
6
S
2
Posts: 55
Reputation: 614

Post » Wed Feb 12, 2014 7:14 pm

Okay, so I actually managed to introduce randomness into the angle part of the equation so that each new orbit is created at a different angle.

So I'm not getting bunching up in the corners, but all my objects go in and out at the same time. i.e. all bodies fly over/under player object at the same time and out at the same time.

Is there any way to stagger the orbits of these objects so that they are all at different points in their orbits and don't all 'come in and out' at the same time?

Here are the equations I'm using:

x: (cos(time*300)*Self.x_motion)*cos(Self.orbitAngle) - (sin(time*300)*Self.y_motion)*sin(Self.orbitAngle) + Player.X

Y: (sin(time*300)*Self.y_motion)*cos(Self.orbitAngle) + (cos(time*300)*Self.x_motion)*sin(Self.orbitAngle) + Player.Y

x_motion, y_motion and orbitAngle are set to a random number within a range when collided with by the player before it starts orbiting around them - meaning that each has a slightly different ellipse and angle of orbit. :-)

The 'self' is the object doing the orbiting, in case that's not clear.

I hope that at least the above helps someone! But could someone else help me with the above?

Cheers.
B
6
S
2
Posts: 55
Reputation: 614

Post » Wed Feb 12, 2014 8:13 pm

Replace "time*300" with "time*300+self.offset" where "offset" is a degree offset in the motion.
B
91
S
31
G
103
Posts: 5,237
Reputation: 67,760

Post » Wed Feb 12, 2014 8:25 pm

Simple, and effective!

You, sir are a legend! Thank you, that's exactly what I was looking for.

How do I change header to 'solved'?
Psynaptik2014-02-12 20:26:34
B
6
S
2
Posts: 55
Reputation: 614


Return to How do I....?

Who is online

Users browsing this forum: bluesun66 and 10 guests