# How do I make a Hinge joint move slowly?

I made a long cube with a hinge joint in the middle of it. I want the player to jump on the cube and I want the cube to slowly rotate on the Z axis as long as force is applied to it. What is happening is as soon as the player jumps on the cube it rotates quickly and the player instantly falls off.

This is a visual example of what I want to happen.

Notice how when the player jumps onto the platform how it moves?

That’s what I want to happen.

## Scene Setup: In Hierarchy create an empty game object and add the Hinge Joint component to that object, rename it Hinge (for this example). Then create a cube (or place your model) as a child of the Hinge and add the Rigidbody component to it as well a the collider (I named this one Platform for testing).

Component Setup:
On the Hinge object, set the Rigidbody to be “IsKinematic = true”. In the Hinge Joint component, drag the Platform object into the “Connected Body”. Then there are some variables in the Hinge Joint component that you will want to play with until it feels right for your game.

• Use Spring: True
• Spring Value: How much the platform will push back to its original position
• Damper: “The give”, what will stop the platform from spinning fast when you hop on
• Use Limits: true
• Min/Max: The maximum amount of angle that the platform can tilt

I’ve added a picture of the setup that worked for my test using a standard 3D cube and Rigidbody (Mass 1) as the player jumping onto the platform.

I figured out a solution. I had to make 5 zones on my object. 1 zone with -0.05 rotation on the z axis. Another zone with -0.025 rotation on the z axis. A middle zone with no rotation. The 4th zone with 0.025 rotation on the z axis and the 5th zone with 0.05 rotation on the z axis. Each zone is a cube parented to the mainobject which is the platform the player walks on that tilts. The zones are cubes with the mesh renderer disabled and istrigger is selected on the box collider in it.

This is my code for a zone. Each zone has to have the script attached and the Z axis value has to be changed on each one to allow it to work. It works beautifully.

``````public class RotateCubeZone2 : MonoBehaviour
{
public bool PlayerInZone = false;
public GameObject MainObject;
public Vector3 Rotation;
public Vector3 RotateBack;
public Vector3 RotateForward;
public GameObject Player;
public bool PlayerWasInZone;
public Quaternion ZeroRotate = Quaternion.Euler(new Vector3(0f, 0f, 0));

// Update is called once per frame
void Update()
{

if (PlayerInZone == true)
{

MainObject.transform.Rotate(Rotation);
}

if (MainObject.transform.rotation ==ZeroRotate)
{
return;
}

if (PlayerInZone== false && MainObject.transform.rotation != Quaternion.Euler(new Vector3(0f, 0f, 0))  )
{
if (MainObject.transform.rotation.z > 0)
{
MainObject.transform.Rotate(RotateForward);
}

if (MainObject.transform.rotation.z < 0)
{
MainObject.transform.Rotate(RotateBack);
}
}

}

private void OnTriggerEnter(Collider other)
{
if (other.gameObject == Player)
{
PlayerInZone = true;
PlayerWasInZone = false;

}
}

private void OnTriggerExit(Collider other)
{
if (other.gameObject == Player)
{
PlayerInZone = false;
PlayerWasInZone = true;
}

}

}
``````