I need to make an object to follow mouse position, but object is supposed to be closer to the camera.
I tried to normalize rayCastHit Vector and then multiply it. Another thing I did was just dividing rayCastHit Vector by some num. Neither of the methods worked.
Vector3 vector = new Vector3(1, 2, 3);
Vector3 vector1 = new Vector3(1, 4, 5);
Gizmos.color = Color.red;
Gizmos.DrawLine(vector1, vector.normalized);
Gizmos.color = Color.green;
Gizmos.DrawLine(vector1, vector.normalized * 2);
CodePudding user response:
Gizmos.DrawLine
requires a start and end position!
You seem to be passing in a start position and a direction.
Either do
Gizmos.DrawLine(vector1, vector1 vector.normalized * 2);
Or rather use Gizmos.DrawRay
instead which takes a start position and a direction
Gizmos.DrawRay(vector1, vector.normalized * 2);
Or in case the vector
actually is an end position you rather want to do
Gizmos.DrawLine(vector1, vector1 (vector - vector1).normalized * 2);
Or accordingly
Gizmos.DrawRay(vector1, (vector - vector1).normalized * 2);