This question is about the Unity C# project.
I know the ray from the camera and the normal vector at the hit point.
Ray from the camera utilizes Camera.main.ScreenPointToRay();
I want to get the intersection of the y-axis values with different ray and normal vectors.
The code and results are as follows.
Ray ray3 = Camera.main.ScreenPointToRay(new Vector3(540, 0));
Debug.DrawRay(ray3.origin, ray3.direction * 10f, Color.yellow, 5f);
Ray ray4 = Camera.main.ScreenPointToRay(new Vector3(540, 499));
Debug.DrawRay(ray4.origin, ray4.direction * 10f, Color.yellow, 5f);
if (Physics.Raycast(ray3, out hit, Mathf.Infinity))
{
var normal = hit.normal;
Vector3 cyanLine = hit.point + normal * 100f;
}
ray3 is the below yellow line. ray4 is the above yellow line.
the cyan line is normal vector.
The x-axis values are the same, only the y-axis values are different, so the two lines are intersecting each other.
I'd like to know the coordinates of the intersection of Cyan Line and the above yellow ray.
How can I get this value. Thank you in advance.