LockConstaint and Pivot Constraints

I have a simple question. All physics constraints types take some pivot point and axis. For example Class LockConstraint.
What I can’t figure out is how do I choose the vectors for PivotA, PivotB and AxisA and AxisB, as I don’t seem to understand what these vectors are supposed to refer to.
Can you please guide me to some resources or help me understand these Pivot vectors that I need to choose to create better constraints?
Here is the playground code : https://playground.babylonjs.com/#KD70VN#1

Once you try to move the cart around with WASD keys, you will see that the cart and pendulum constraint is not ideal. Please help.

cc @Cedric

The best documentation (that I know :slight_smile: )is here : Babylon.js docs

The key to understand is to think for pivot/axis as local to the body values.

1 Like

Yes, I have. I guess my question is now that I have applied the constraints.
You can see in playground that when things do render, you have these effect of cylindrical rod drumming on the red box that is cart, rather than acting like a nice rotation axis.
So I am not sure, is it because my constraints are wrong or is it some rendering limitation or physics engine trying to calculate the position of all bodies and getting these weird rendering effect?

I bet it’s setting of the constraint that’s not doing what you want :slight_smile:
I agree constraints are sometimes difficult to set and debug/view properly. That’s something I want to address in coming months.

1 Like

I’m not sure I understand your expected output, but here is an updated PG where your “pendulumbob” is the fixed point by setting it to a static motion (this can be achieved by setting it’s mass to 0 when doing a physic aggregate). The joint you may want form the fixed point to the rod is the ballsocketconstraint as you want full rotation freedom, the other joint from pendulum to cart may be a lockconstraint.

Also updated the gravity set in the scene, and the impulses are all being applied to the cart. The ground is also set to a lower level, because I think it was colliding with your objects.

One thing that helps is setting the mass of the rod and the cart to be the same so that the rod can hold the cart.

Updated PG: