Search code examples
javalibgdx2dmove

libgdx box2d body - How to move body at constant speed with specific direction?


When I touch the screen the body is moving gradually and slowing down when the touch point is near. My problem is I want to move the body at constant speed let say the given speed is 60 kpH, the body should move starting with speed of 60 kpH until touch point. I'm thinking about the solution was on screen touch, get the angle and then move that body using that angle then add the speed to get the right speed?

enter image description here


Solution

  • I'm not sure if this is the proper way. But when I use .nor() function at the targetDirection.nor(), the body is now moving at constant speed! The problem now is when the direction has reached the body is shaking like in a coma. :)