I have a camera. It has a x-axis vector in global position (transform.forward). How to extend this "ray" until Y is 0?

Now done through the loop, add in transform.position + transform.forward, until Y becomes 0. Otherwise, it never came up. I found an approximate name of the problem as “finding a trace of a line”

That is, we need a point of intersection with the axis in the direction of transform.forward

    1 answer 1

    vector equation

    -> -> -> r = r0 + t*u 

    where r0 is the camera coordinates (x, y, z), u is the direction vector (camera.transform.forward in the world reference system).

    based on the fact that ry = 0 we find t:

      0 = r0.y + t*uy -> t = -(r0.y/uy) 

    further we find x and z:

      rx = r0.x + t*ux rz = r0.z + t*uz 

    PS This is not to extend the vector to the axis, but to find the point of intersection of the line (above) and the plane (Y = 0) :-) Unity doesn’t like to interpret concepts so “freely”, keep in mind :-)

    ALSO, take the module Math3D - there are all the basic functions, including the intersection of the line with the plane.

    • Nobody likes liberty) but I can’t just put it right more correctly, I have to pull this whole thing up. The main point was to get the message across, thanks for the reply! took Math3d, everything worked out. - noadev