I’m struggling with physics constraints. What I have is a rectangular plate that tips over when a impulse is applied. It pivoits about its local x-axis. I have set this up successfully with the local x defined parallel to the world x. (The plate origin is always at y=0.)
…
Node* targetNode = node;
Constraint* pinConstraint = targetNode->CreateComponent();
pinConstraint->SetConstraintType(CONSTRAINT_HINGE);
pinConstraint->SetWorldPosition(targetNode->GetWorldPosition());
pinConstraint->SetAxis(Vector3(Vector3::RIGHT));
pinConstraint->SetOtherAxis(Vector3(Vector3::RIGHT));
pinConstraint->SetLowLimit(Vector2(0.0f, 0.0f));
pinConstraint->SetHighLimit(Vector2(90.0f, 0.0f));
My problem comes in when I set the plate up at an arbitrary rotation about the y-axis. What I would like to know is how to determine the OtherAxis when the plate is rotated.
I have tried all sorts of ways using pinConstraint->SetAxis and pinConstraint->SetPosition, but I’m missing something. I can see the constraint when I turn on debug geometry, but I still can’t seem to figure out how to get the OtherAxis aligned with the local axis correctly.
BTW, the plate node’s parent is the floor/world located at y=0.