So for my game I am trying to make a catapult. to give the effect of a catapult the body has to quickly rotate. what I'm trying to do is make the body rotate 45 degrees and let gravity do it's thing by putting it down on the ground again.
i tried using setangular velocity but that doesnt seem to do the trick. does anyone have suggestion?
Well, if it's not too late, my suggestion would be to use a b2RevoluteJoint and accompanying b2RevoluteJointDef to set up a motor joint. Enable joint limits and set them to your desired angles of minimum and maximum revolution. Then in your game loop whenever you want the catapult to fire, enable the motor using joint->EnableMotor(true) and set the joint rotation velocity using joint->SetMotorSpeed() to something appropriate. Then use joint->GetJointAngle() to check if the angle has reached where you want it to, and if it has, just do joint->EnableMotor(false). This should allow the catapult to return under gravity power to its starting position.
I tried a little setup in the testbed and it seemed to work OK. Just remember to set the threshold angle you check for to be a little less than the max constraint angle to allow for rounding errors and to have the catapult actually relax after firing.