why ordering in addConstraint is important and what is diffrence?
A.physicsBody.addConstraint(B.physicsBody, axleBodyConstraint);
B.physicsBody.addConstraint(A.physicsBody, axleBodyConstraint);
when i change ordering, constraint be unstable and not work correctly?
Constraints are relative, in the same way that the orientations of nodes are relative to their parent nodes in a scene hierarchy.
As a general rule of thumb,
- The parent body (the one you call .addConstraint on) is the “driver”, or more static body. It’s the one whose orientation you want to define yourself, or keep under your control in code. In a door hinge example, this would be the wall.
- The child body (the argument) is the “driven”, or more dynamic body. It’s the one that should move on its own according to the constraint. In a door hinge example, this would be the door itself.
2 Likes