In libGDX Box2D i have a DynamicBody "body" and StaticBody "anchor" and its joint from "pivot joint point" and body can turning around "pivot point" and working perfect (position 2).
Body body = Box2DUtil.addRectangle(BodyDef.BodyType.DynamicBody);
Body anchor = Box2DUtil.addRectangle(BodyDef.BodyType.StaticBody);
RevoluteJointDef revoluteJointDef = new RevoluteJointDef();
revoluteJointDef.initialize(anchor, body, anchor.getWorldCenter());
world.createJoint(revoluteJointDef);
But i want rotate the "body" to spesific angle, when simulation is running and gravity=10 etc. the body is turning to bottom its OK. When i click a button i want turn body to "myNewAngle" position As it is shown in the picture (position 1)
float myNewAngle = 0;
body.setType(BodyDef.BodyType.StaticBody);//for not effected from gravity
body.setTransform(body.getPosition(), lastAngle * MathUtils.degreesToRadians);
My problem is my "body" is turning around its origin (position 3) i want turn it aroud "pivot point" i set "body.setTransform(anchor.getPosition()" but its not worked. I can't do it with "motor" too.
How can i turn "body" around "pivot point" dynamical?
