I’d like, at each frame, to move, scale and rotate a given cylinder so that it behaves like a ‘rope’ between two points.
I have this code at the moment, but it doesn’t work at all like intended :
hook.transform.position = (rightHandPosition + hookDestination)/2;
hook.transform.localScale = new Vector3(0.5F, Vector3.Magnitude(hookDestination - rightHandPosition), 0.5F);
hook.transform.rotation = Quaternion.Euler(hookDestination - rightHandPosition);
As you can guess the two points are rightHandPosition
and hookDestination
.
For now, the cylinder spawns at ‘random’ locations, with ‘random’ rotations and enormous scales.
How can I fix it ?