How do I attach a string to a pendulum in Havok?

I’m trying out a pendulum using a DistanceConstraint.
babylonjs_physics_sample_002

I thought it would be a good idea to connect a string (cylinder in this case) to the ball, so I tried that, but it was displayed vertically, and I couldn’t get it to look like it was hanging from a string.

What should I do to realize the string?
Do you need to understand 6DoF?

would like to realize Pendulum wave with Havok.

1 Like

The cylinder isn’t a physical body itself, so we need to find its rotation ourselves. Thankfully, it’s pretty easy, you just need to compute the rotation that gets from its default up vector (0,1,0) to the vector formed between the ball and the box: Experiment swinging the pendulum | Babylon.js Playground (babylonjs.com)

Pretty cool looking PG btw! Can we add it to the docs? :slight_smile:

4 Likes

Thank you for teaching me how to calculate it.
Of course, feel free to add samples to the documentation.

2 Likes

Added a PR :wink: Add pendulum example to constraints by carolhmj · Pull Request #972 · BabylonJS/Documentation (github.com)

1 Like

Thank you for adding it to the documentation sample.

BTW, I have a simple question about pendulums.
It seems that the pendulum’s swing gradually slows down, but where are its parameters specified? I tried changing friction and restitution, but it didn’t seem to have anything to do with damping.

There’s a separate parameter for damping, there is body.setLinearDamping and body.setAngularDamping

1 Like

Thank you for teaching me that method.
However, it seemed that even if I set it to zero, I could not completely eliminate the attenuation. Am I using something wrong?

agg1.body.setAngularDamping(0)
agg1.body.setLinearDamping(0);

Oh, you’re not! There is a bug with the damping currently, I had forgotten about it but @eoin reminded me :slight_smile: It will be fixed in the next plugin update! Spinning physics object stops abruptly (havok) - #3 by eoin

1 Like