drag rotation

GuardianofgahooleGuardianofgahoole Member Posts: 15
edited November -1 in Working with GS (Mac)
How would you make it so if i drag something then it rotates with finger?

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    A quick way would be to do the following--

    In an actor prototype:

    Timer (every .025 seconds)
    ----When actor receives event: (touch) is: (inside)
    --------Change Attribute: (self.Rotation) To: vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    RThurman said:
    A quick way would be to do the following--

    In an actor prototype:

    Timer (every .025 seconds)
    ----When actor receives event: (touch) is: (inside)
    --------Change Attribute: (self.Rotation) To: vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )

    RThurman said:
    A quick way would be to do the following--

    In an actor prototype:

    Timer (every .025 seconds)
    ----When actor receives event: (touch) is: (inside)
    --------Change Attribute: (self.Rotation) To: vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )

    That causes very jerky movements, not really what you want.

    Best way to do it is as so:

    Have 3 self interger attirbutes. StartRotation, StartAngle, andMyAngle

    When actor receives event touch is pressed:

    -change attribute StartRotation to: self rotation

    -change attribute StartAngle to: vectorToAngle(mouse.position.x-self.position.x,mouse.position.y-self.position.y)

    -constrain attribute MyAngle to: vectorToAngle(mouse.position.x-self.position.x,mouse.position.y-self.position.y)

    -constrain attribute self.rotation to: startRotation+(MyAngle-StartAngle)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @JohnPapiomitis
    Yes -- that smooths out the initial lurch very nicely!
Sign In or Register to comment.