I am trying to get a bodies rotation angle to stop incrementing to huge numbers. Usually if numbers get too high the program crashes. Not sure if Box2D deals with this. If it does then all I really need to worry about is a way to get a usable angle. Which should be quite easy to work out.
This is the only line that I’m using for rotating the body:
if(GameInputs.keyHolding(Keys.Z)) body1.applyTorque(0.01f, true);
These are the only lines I have for resetting the rotation:
if(body1.getAngle() > 359 * MathUtils.degreesToRadians){
body1.setTransform(body1.getPosition(), 0);
}
if(body1.getAngle() < 0){
body1.setTransform(body1.getPosition(), 359 * MathUtils.degreesToRadians);
}
As you can see every time it resets, the body jumps a little. I am not moving the body any other way, only with those lines. You’d expect that by giving it the same position before stepping the world, would have no effect. How can I reset the body rotation value?
q_RwtDMF3tk
Thanks.