0
votes

I have a box2D body that has two polygon fixtures attached to it. When I call setTransform (passing in the values 0,0 for position and 1 for angle/rotation) it should rotate to 1 degree, right? Well for some reason it rotates to roughly 45 degrees (not exactly). When I set it to 5 degrees, it is a little less than 1 full rotation. Why might this be happening?

Extra info:
-The world has 0 gravity and sleep set to false.
-The body is set to kinematic.
-I use a box2DDebugRenderer to render the bodies.
-The body has 2 polygon fixtures attached to it.
-I am using a virtual world size of 50x50.

Thanks! If you need extra info, feel free to ask!

1

1 Answers

0
votes

I found the solution for those who are having the same problem! I had to convert degrees to radians, using the code below :

private static final double DEGREES_TO_RADIANS = (double)(Math.PI/180);
float angle = (float) (45*DEGREES_TO_RADIANS);
object.body.setTransform(object.body.getWorldCenter(), angle);