Right now the mouse is positioned behind the arrow, it’s similar to if you pulled an arrow from a bow. Also, you can adjust the direction of the arrow by moving your mouse around. However, I would like for the arrow to become shorter when the player moves their mouse toward the arrow while maintaining the ability to rotate it with their mouse. Is this possible? I guess it’s similar to a pool game?
Maybe I can use the mid point of the arrow as something to calculate the distance from the mouse position? The closer the mouse is to it the shorter it becomes.
well, if we fix the base of the arrow at point A, and name mouse position M, then
var direction = (A - M).normalized;
var distance = (M - A).magnitude;
you can now use this distance to change the length or scale of the arrow like so
arrowLength = distance;
or fully formed
arrow.transform.localRotation = Quaternion.FromToRotation(originalRotation, (A - M).normalized);
arrow.transform.localScale = (M - A).magnitude * Vector3.one;
voila. this assumes that arrow’s pivot is at the base.
originalRotation is supposed to be Vector3.right if your original non-animated prefab was looking to the right, or up if it was looking up, and so on.