orbit around point with key controls

SEMASEMA Member Posts: 161

I know this have been covered many times but I want to do a project: let's say if the mouse button is down the actor will orbit clockwise and if I release it counter clockwise.

Comments

  • SEMASEMA Member Posts: 161
    edited November 2016

    help

  • SocksSocks London, UK.Member Posts: 12,822

    Constrain X to radius*cos(self.rotation)+X centre point
    Constrain Y to radius*sin (self.rotation)+Y centre point

    When mouse button is down:
    --Rotate Clockwise
    Otherwise
    --Rotate Counter-Clockwise

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2016

    Smoother version (a less mechanical change in direction)

    Constrain X to radius*cos(self.rotation)+X centre point
    Constrain Y to radius*sin (self.rotation)+Y centre point

    When mouse button is down:
    --When Angular Velocity > -90
    ----Constrain Angular Velocity to Angular Velocity-5
    Otherwise
    --When Angular Velocity < 90
    ----Constrain Angular Velocity to Angular Velocity+5

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @SEMA

    Here is another simple way:

    In the actor, under Motion, set the X to some offset like 200, and Pin to on.
    Then use the rotate behavior:

    Rule: If mouse is pressed
             Rotate Clockwise
    Otherwise
             Rotate CounterClockwise
    End rule
    
  • SEMASEMA Member Posts: 161

    @Socks amazing thank you

  • SocksSocks London, UK.Member Posts: 12,822

    @Hopscotch said:
    @SEMA

    Here is another simple way:

    In the actor, under Motion, set the X to some offset like 200, and Pin to on.
    Then use the rotate behavior:

    Rule: If mouse is pressed
             Rotate Clockwise
    Otherwise
             Rotate CounterClockwise
    End rule
    

    Neat !

Sign In or Register to comment.