I’ve been working hard the last week to came up with a solution to this problem. See the video below please, it’s worth more than any word.
The lever is a child of it’s pivot. The pivot has a hinge joint, limited in the rage of the lever movement.
Thru a script, when I press the left button, an up torque is applied. If no key is pressed, a down torque is applied by default (to keep it down). NO animations are used, only straight unity physics (using animations already gave me a worst failure!).
If I were a damn sphere of mass 0.1 if would surely get the hell out of there if i were kicked by a mass 1 angry lever powered by a constant torque of 10000. I even set the collider of the lever to “bouncy”.
You may need the script attached if you want to investigate the problem.
#pragma strict
private var leftDown : boolean = false;
function Update () {
if (Input.GetButtonDown("left")){
rigidbody.AddTorque(Vector3.down * 10000);
leftDown = true;
} else if (Input.GetButtonUp("left")) {
leftDown = false;
rigidbody.AddTorque(Vector3.up * 10000);
}
}
function FixedUpdate(){
if (leftDown)
rigidbody.AddTorque(Vector3.down * 10000);
if (!leftDown)
rigidbody.AddTorque(Vector3.up * 10000);
}