What I am trying to figure out is how can I do an alighnment on a vertical/horizontal axis relative to a mesh.
I use a raycast to position my points once 2 points have been set the line renderer renders between the 2 points with SetPosition and Quaternion.LookAt(hit.normal) to set the normal and the line is set to world space position. What I am trying to achieve is once the line renderer is set, with a button i want that line renderer to be set or rotated on a straight angle either vertically or horizontally relative to the mesh. (I already know how to setup the button. Anyone with helpfull advice would be great. thank you
ou want to use the vector dot product. The dot product of a vector tells you how much one vector points in the direction of another vector. If one of the vectors is normalized, then you could use the dot product to get the point your looking for.
As an example, let’s say you have the second position of the line and you want get its position along the transforms forward normal. First subtract the first position of the line from the second, so that the second is centered around the origin, then get the dot product between the forward normal and the new second position. Then multiply the dot product by the forward transform to get the point.