Hi all,
I have been searching on the internet for a while now for a way to stop a b2Body from moving once it has reached a given position and can't find any proper solutions for my situation. Let me explain what I have. I am working on a top down game for the Iphone, so gravity is 0. I have a player, which I want to move to a touched location on the screen. I have read online that its possible by manually moving the b2Body's transform, but as stated in the documentation "Manipulating a body's transform may cause non-physical behavior", so I don't want to go that route. Another way I read online was by using a b2MouseJoint, but I read that it may cause non-physical behavior as well, and since I want more than just my player to move in the game eventually, I wouldn't want to make a b2MouseJoint for each entity in the game to move to a designated location.
What I am doing currently to move my character is setting its Linear Velocity based on the touch location, but the player will continue to move in this direction forever unless stopped. I know that I can set the players Linear Velocity to 0 once I reach the desired point, so how can I tell that the player, or AI in the future, has reached their stopping position in order to set their velocity to 0? Or is there another way to do this?
Thanks,
I have been searching on the internet for a while now for a way to stop a b2Body from moving once it has reached a given position and can't find any proper solutions for my situation. Let me explain what I have. I am working on a top down game for the Iphone, so gravity is 0. I have a player, which I want to move to a touched location on the screen. I have read online that its possible by manually moving the b2Body's transform, but as stated in the documentation "Manipulating a body's transform may cause non-physical behavior", so I don't want to go that route. Another way I read online was by using a b2MouseJoint, but I read that it may cause non-physical behavior as well, and since I want more than just my player to move in the game eventually, I wouldn't want to make a b2MouseJoint for each entity in the game to move to a designated location.
What I am doing currently to move my character is setting its Linear Velocity based on the touch location, but the player will continue to move in this direction forever unless stopped. I know that I can set the players Linear Velocity to 0 once I reach the desired point, so how can I tell that the player, or AI in the future, has reached their stopping position in order to set their velocity to 0? Or is there another way to do this?
Thanks,