- Home /
Rotation to align between two vectors but with preserved Camera Z axis
Vector3 firstPoint = _waypoints.First();
Vector3 lastPoint = _waypoints.Last();
Vector3 relativePos = lastPoint - firstPoint;
Vector3 middlePoint = Vector3.Lerp(firstPoint, lastPoint, 0.5f);
Instantiate(prefab, firstPoint, Quaternion.identity);
Instantiate(prefab, lastPoint, Quaternion.identity);
GameObject slash = Instantiate(slashPrefab, middlePoint, player.rotation);
slash.transform.rotation = Quaternion.FromToRotation(Vector3.right, relativePos);
Given slash prefab (white mark on screenshot) I want it to point always in the direction I'm looking (player z-axis) but be rotated so it's pointing from cube to cube as the purple lines.
How can I combine player.rotation/forward with the Quaternion.FromToRotation(Vector3.right, relativePos)
inkedinkedunity-rw9adtduxi-li2.jpg
(432.1 kB)
Comment