# Pendulum like effect with 2 degrees of freedom movable pivot

Hi all,

I’m trying to recreate the physics which can be seen in:

Terrafire:

Hopefully you get the idea from the videos - there is a ship with some mass, a ball with some mass and a rope which hangs the ball from the ship.

As the player moves the ship the bomb moves as if it is tethered with a rope, the bomb swings around underneath the ship (kind of like a pendulum). One other thing to note is that the bomb effects the ship, so it will pull the ship in the direction it is travelling (i.e. if the player is moving right and the bomb is trailing behind, then the player suddenly stops the bomb will swing out to the right and the ship will be pulled the right a bit).

With the explanation over I’ll explain what I’ve done so far:

I’ve created the ship movement code which works as intended using rigid body physics.

I’ve given as good a go as I can at creating the pendulum script, it’s kind of working but it has 3 major problems (in order of importance):

1. The ball doesn’t stay tethered, it acts as if it’s attached with elastic rather than rope. Eventually equilibrium returns but it shouldn’t be “elastic” at all, when tight the rope should stop the ball from travelling any further from the ship (it should just act as a hinge joint at this point).

2. The pendulum motion doesn’t slow down, once the players ship becomes out of line with the ball (vertically) then the pendulum motion starts and it swings back and forth for ever, but I want it to slow down and eventually settle beneath the ship.

3. The ship isn’t affected by the ball yet - this is fine for now as I just want to get the ball swinging correctly. But how would I go about getting the balls momentum to affect the ship in the future?

I’ve attached the full project, the pendulum script is fully commented, any help is greatly appreciated!

2154415–142265–Terra.7z (93.5 KB)

Instead of using your script, I used a chain of configurable joints.
Check out the unitypackage and play around with the settings to get what youd like.

Nice one, it’s not doing exactly what I was aiming for but it’s a good starting point, thanks for taking the time to do that dude!

1 Like