So I have just started with Unity and I am not too familiar with it, the same goes for Quanternions.
So as far as I can tell, the way to create a normal to a plane, given 2 vectors, should look something like this:
Quaternion newQuaternion(Transform start, Transform target)
{
Vector3 f = start.TransformDirection(Vector3.forward);
Vector3 t = target.position - start.position;
Vector3 c = Vector3.Cross(f, t);
Quaternion q = new Quaternion(c.x, c.y, c.z, Vector3.Dot(f, t));
return q;
}
However, when testing it, by drawing a line with this :
Debug.DrawLine(transform.position, test * -transform.up);
Does not always line up with this line (which it should):
Debug.DrawLine(transform.position, target.position, Color.red);
I realize that Unity has built in LookAt functions and other helpful functions, but I am trying to learn it on my own.
Thank you in advance for the help.