Hello. I have a rather simple, vector-related issue. It’s a really simple thing which I can’t get to work.
I have a ray which comes from an object named “A”. The ray hits a surface called “B”. How can I get a vector that is aligned to the surface and points at A.forward’s direction. This might be confusing, so I drew a little scheme:
So in this scheme, Vector 1 would be the ray that hits the surface. As you can see, the objects is facing forward (so Desired vector DOT object.forward is bigger than 0) but is also facing a little upwards. However, the desired vector replicates the object’s forward but it’s not facing upwards, instead it’s mapped to the surface.
So how can I do this ? I tried crossing vectors, subtracting and normalizing…pretty much nothing that came to mind worked.
EDIT: just had an idea, but still can’t get it to work properly. Here’s some code:
var rotateVector : Quaternion = Quaternion.AngleAxis(90-Vector3.Angle(object.forward, surfaceNormal), object.right);
var desiredVector: Vector3 = rotate the object.forward vector with rotateVector…somehow.
If I manage to rotate the vector, would that work ?
