move in a circle

-Timo--Timo- Member Posts: 2,313
how can you move a actor in a prefect circle? I dont want it to rotate I only want to move it in a circle.
can someone help me?

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    @timolapre1998

    Constrain its X position to AAA*sin(self.Time*BBB)+CCC
    Constrain its Y position to AAA*cos(self.Time*BBB)+CCC

    AAA = radius of circle
    BBB = speed of movement
    CCC = centre point of the circle
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    @Socks X should be cosine, and Y should be sine.
  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    @Socks X should be cosine, and Y should be sine.
    @CodeMonkey

    Not nessecerally ! : ) They can be whichever way around you want depending on which direction you want the object to move in and/or where the circle starts.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Technically yes, switching sin/cos is not a problem and it changes the direction. But if you teach people that way, then they learn incorrectly to associate x with sine and y with cosine. So when they use the angle of the actor where the coordinate system starts with 0 degrees at East going counter-clockwise, they'll ask why things don't work the same.

    The best and easiest way to switch direction of it is to have the value within the sine and cosine to decrease towards -∞ if it was increasing or vice versa and increase towards ∞ if it was decreasing.
  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    Technically yes, switching sin/cos is not a problem and it changes the direction. But if you teach people that way, then they learn incorrectly to associate x with sine and y with cosine. So when they use the angle of the actor where the coordinate system starts with 0 degrees at East going counter-clockwise, they'll ask why things don't work the same.
    @CodeMonkey

    I can't see that being a problem, as I've got it above the object starts at '12 O'clock' and moves clockwise, I suspect this is going to be what most people are after rather than an object starting at '3 O'clock' and moving anti-clockwise'.

    Also I don't really associate X with sine and Y with cosine, I just see one as being out of phase or offset by 90° - in fact (as I'm more than sure you already know) you don't even need to use both sin and cos to move objects in a circle, one will do the trick just fine, you could just stick the phase offset onto whatever you are using for the angle - in this scenario you only need change between a '-' and a '+' to change direction.

    This sort of thing:

    Clockwise using only 'sin':
    X = AAA*sin( game.Time *BBB)+CCC
    Y = AAA*sin( game.Time *BBB+90)+CCC

    Counterclockwise using only 'sin':
    X = AAA*sin( game.Time *BBB)+CCC
    Y = AAA*sin( game.Time *BBB-90)+CCC
    The best and easiest way to switch direction . . . .
    No way, mine's the bestest ! And I'll fight anyone who says otherwise !

    #PedantWars
    #SineWars

    ;)
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803


    Also I don't really associate X with sine and Y with cosine, I just see one as being out of phase or offset by 90°
    True, but some people haven't taken Trigonometry yet and I'd like them to take what they learn in GameSalad into other aspects in life. Basics first. Then they can learn about the phase offset.
  • SocksSocks London, UK.Member Posts: 12,822
    . . . I'd like them to take what they learn in GameSalad into other aspects in life.
    I did that and now my toilet crashes when I try and enter a value over 30 (don't ask).

    :P
Sign In or Register to comment.