Sine circle

This forum is currently in read-only mode.
From the Asset Store
Dodge the spikes and collect the gems as you orbit the circle.
  • Hey chaps

    I am trying to make a circle path using sine on the x and y axis.

    Thanks to Shviller, I know that, using the sine behaviour I can achieve this with a 25% offset on one axis. However I want to use events to control it, and I just can't get the timing right, I am not sure how to offset the values with events.

    sin(timer*0.10) * 10

    So I have something along these lines, and have tried all sorts of combinations of values.

    sin(timer*0.025) * 10

    sin(timer*0.025) * 2.5

    sin(timer*0.10) * 2.5

    So I am thinking that the offset is some other value, but I am not sure.

    Anyone have any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • cos and sin expect a value in degree and return a value based on the unit circle (so they return [-1,+1])

    To position something on a circle around a center:

    x = center_X + cos(angle) * radius

    y = center_Y + sin(angle) * radius

    To move something circular around a center over time:

    angle = angle + amountofchangepersecond * TimeDelta

    x = center_X + cos(angle) * radius

    y = center_Y + sin(angle) * radius

    You may also change angle and/or radius independently for x and y which will have various effects, like shaping an ellipse instead of a circle and much more.

  • Oh you are absolutely fantastic Tulamide, always so helpful. I was specifically looking for elliptical shapes as well. Cheers!

  • tulamide - lets say you have a square moving around the elliptical path, how do you angle it to aim always at the center?

  • That depends on the exact situation. In the example above, I made 3years ago, the angle is from the center's point of view. In this case it is easy: Just use the opposite angle. Easiest way to do so is by adding 180:

    angle = angle + amountofchangepersecond * TimeDelta

    x = center_X + cos(angle) * radius

    y = center_Y + sin(angle) * radius

    square_angle = angle + 180

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