- Home /
How could I emulate a cherry picker arm's rotation?
I am attempting to get the rotation of an arm below a moving platform correct. However, at the moment I've only been able to get it bending partially and never at the right angles.
This is the style I'm trying to achieve. The further from the ground the platform is, the more the arm should rotate in order to look like a proper support. The closer to the ground, however, it should go flatter.
The code I came up with only produces a couple degrees of movement that look stiff:
private void ManipulateArmDirection()
{
Vector2 Ground = new Vector2(0, GameController.Instance.startingHeight);
float HeightDifference = Mathf.Round(Vector2.Distance(transform.position, Ground));
Quaternion Rotation = Quaternion.Euler(new Vector3(0, 0, HeightDifference * 2));
PlatformArm.rotation = Quaternion.Lerp(PlatformArm.rotation, Rotation, Time.deltaTime * 20);
}
platformexample.png
(30.7 kB)
Comment