completely stop actor from moving when tapping a button

iPhoneDevForMeiPhoneDevForMe Member Posts: 362
edited November -1 in Working with GS (Mac)
My actor is set to move left and right based on accelerometer input using acceleration!

I want to be able to tap a button, and when this button is tapped, stop the actor moving.

I currently have the rules set up with a boolean game attribute called moving. If moving is true, accelerate (the direction of course is based on the accelerometer). When my button is tapped, change game.moving to false.

This stops the actor by decelerating, but I want it to stop immediately.

If I change from accelerate to move, the movement is too choppy, so is there another way to do this?

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    When touched is pressed spawn non moving version of the actor and destroy the moving version. You can NOT change any physics after a scene has been loaded so don't put those into change attribute behaviors as nothing will happen.
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    @scitunes

    Works like a charm! Im gonna try playing with showing/hiding the actor for a more smooth gameplay! Thanks a lot!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You can also try setting self.Motion.Linear.X To: 0 and self.Motion.Linear.Y To: 0 when you push the button.
  • nulonulo Member Posts: 315
    firemaplegames said:
    You can also try setting self.Motion.Linear.X To: 0 and self.Motion.Linear.Y To: 0 when you push the button.

  • VoidedSkyVoidedSky Member Posts: 1,095
    Great tips, But Instead of changing the linear attributes, you might want to constrain them, because if you don't, then the object is likely to move if it is collided with.
Sign In or Register to comment.