3
\$\begingroup\$

I would like to replicate the behavior of a flexible pole as used for pole vault.

Can somebody give me some inspiration how to simulate that with Box2D? Should I connect multiple objects with flexible joints, or is there another way?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

If you don't want to worry about the pole-vault colliding with anything during the vault, you can simulate it using a simple spring-mass-damper system, and you can just animate the pole deforming artificially. The pole can be considered to be a (very stiff) spring. The rest length of the spring is the length of the pole. This is actually a mathematical model

When the player is about to pole-vault, find a point on the ground in front of the player for the pole to attach to. Then, create a spring joint between the player and the ground point. If the player has enough forward momentum, he/she will vault through the air. Tune the stiffness of the spring until you get a result that you like.

As for animating the pole, you can check the length of the spring against its rest length. If the length is significantly shorter, then the pole is compressing, and you can draw a "compressed pole" sprite or curve. Otherwise, the pole is straight.

\$\endgroup\$
1
\$\begingroup\$

You can take a look at the cantilever demo in Box2D. If you use the same strategy you can definitely simulate a pole vault. You'll need pretty stiff revolute joints, and will probably want to set Box2D's iteration count fairly high. Try around 50 or so and lower the number until you see the simulation doesn't perform to your standards.

The idea is to just make a bunch of rectangles and link them together with revolute joints. The revolute joints need to be "soft joints", which means they will be solved as non-rigid. This will make the revolute joint act like a spring. However, since you want the spring to be really stiff for the pole vault you'll need to adjust the frequency and damping factor of the joint's spring. This is also why you'll want a high Box2D iteration count as well, to ensure your large link of rectangles converges properly.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .