Return Angle as Vector 3

Hello,
I have to raycast into a direction to check if there is a clear path between two objects. To do that I need a vector 3 of an angle. How would I do this.

Thanks,

Thor

The vector between two objects is the difference between their transform position vectors. If you can ray cast in that direction, from one of the objects and hit the other, then you have line of sight.

If you have angle A, which will be a Quaternion, then a vector pointing that way is A*Vector3.forward; If you have an angle in mind, like 30 degrees on y, 5 tilted up on x, then Quaternion.Euler(-5,30,0)*Vector3.forward; gives a length 1 V3 aimed that way (negative x is up – left-handed rule.)

Most people would probably just guess that Vector3(1,0.1f,0.8f) was at about that angle, so is good enough.

transform.forward is shorthand for transform.rotation*Vector3.forward; That math is: Unity thinks 0 degrees on x and y is North. So, Quaternion.identity*Vector3.forward gives back Vector3.forward, unchanged, which is North, which is rotation 00.

As the other posters say, you usually got the angle starting with an aim point or a normal or something like that. So it’s usually easier to just use the starting point directly and skip ever having the angle.