Start elliptical orbit at different points

0 favourites
  • 4 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi there,

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

    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.


  • 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?


  • Replace "time*300" with "time*300+self.offset" where "offset" is a degree offset in the motion.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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'?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)