Help with dynamic Body

Hello guys,

i just run into a problem. i have a dynamic body which represent a moveable plane. this works for now. i´ve disabled the gravity to this body because it should stay in its position.
for now i will only rotate the body around the x- and z-axis but it should stop rotating if it reached an angle. how can i do this ? right now i give this box an velocity setAngularVelocity(PxVec3(0.0f, 0.0f, -5.f*dt)).

Best Regards

Hi there,

Well, if the setAngularVelocity way of doing it works for you, why don’t you just set back the angular velocity to 0 once you reached the orientation that you need ?

If I had to do it myself, I would probably set a constraint between the plane and the world, and work either with angular limits or joint drive on the constraints, you should check the documentation about it.


Hello grandYann,

thanks for the response. i will look into it. do you have a quick example how to set angular limits?

Best Regards

Sure, here’s our way of doing it on a PxD6Joint:

joint->setMotion(PxD6Axis::eX, PxD6Motion::eLOCKED);
joint->setMotion(PxD6Axis::eY, PxD6Motion::eLOCKED);
joint->setMotion(PxD6Axis::eZ, PxD6Motion::eLOCKED);

joint->setProjectionLinearTolerance(0.1f * getPhysXPhysics().getTolerancesScale().length);
joint->setConstraintFlag(PxConstraintFlag::ePROJECTION, true);
//disable contacts between the 2 rigids constrained by this limit
joint->setConstraintFlag(PxConstraintFlag::eCOLLISION_ENABLED, false);

//set flag to show joint in debug visu
joint->setConstraintFlag(PxConstraintFlag::eVISUALIZATION, true);

//spring or contact disk
	PxSpring spring(_jointLimitsStiffness, _jointLimitsDamping);
	joint->setTwistLimit(PxJointAngularLimitPair(-angularLimits.x, angularLimits.x, spring));
	joint->setSwingLimit(PxJointLimitCone(angularLimits.y, angularLimits.z, spring));
	joint->setTwistLimit(PxJointAngularLimitPair(-angularLimits.x, angularLimits.x));
	joint->setSwingLimit(PxJointLimitCone(angularLimits.y, angularLimits.z));