rotation spazing

pinata14pinata14 Member Posts: 150
edited March 2012 in Working with GS (Mac)
hey guys, so right now im using the off center rotation formula and it rotates to my mouse position, but when i get too close, it starts vibrating and glitching out. any ideas how to fix this?

Best Answers

  • pinata14pinata14 Posts: 150
    edited March 2012 Accepted Answer
    hey, thanks, i meant that the actor does move, but it points at the mouse. specifically it is a turret on a tank that can move, but also points towards the mouse as an aiming mechanism. Although you said not much can be done, I have been working on something else and discovered a way to fix it. If anyone would like to know I would be happy to explain the solution.
    Thanks for the attempt though @RThurman
    -Ryan
  • pinata14pinata14 Posts: 150
    Accepted Answer
    @SaladStraightShooter
    hey, could you please implement a way to make the question "answered" for people who solve it themselves so that it does not remain a question on the forums? Thanks,
    Ryan

Answers

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Do you mean you have it rotating over to the mouse position (as in X,Y position)? Or do you mean you have it rotating to point at the mouse position (as in vectorToAngle)?
  • pinata14pinata14 Member Posts: 150
    im using this formula:
    self.SceneX -magnitude( self.OffsetX , self.OffsetY )*cos( self.Rotation +vectorToAngle( self.OffsetX , self.OffsetY ))
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Yes, I assumed you are using that formula.

    My question was about your statement, "... it rotates to my mouse position." The statement was ambiguous, since rotation is about angles, but position is about x,y coordinates.

    Did you mean that the actor is rotating to the mouse's x,y position by rolling over to where the mouse is located? (It chases the mouse around the screen?)

    Or does this statement mean that the actor is rotating to point at the x,y location of the mouse? (It constantly points at the mouse, but stays in at fixed location?)

    I am going to assume that you are meaning that the actor is simply pointing at the mouse's x,y location.

    Generally the 'spazing' comes from two sources:
    1) getting the mouse angle from the center of the actor, instead of the screen coordinates of the rotation point.
    2) extreme sensitivity to changes in angle at close ranges. (eg. a change of 1 pixel = 45 degrees when the mouse is right next to the pivot point. But a change of one pixel = 1 degree when the mouse is 360 pixels from the pivot point.)

    You can't do much about problem #2, but problem #1 is fairly easy to correct. You need to adjust the rotation formula to something like:
    Constrain Attribute: self.Rotation To: vectorToAngle( game.Mouse.Position.X -self.SceneX, game.Mouse.Position.Y -self.SceneY)

    Hope this helps!
    RThurman
Sign In or Register to comment.