- Home /
Difference between local space normal and world space normal
Hi,
I use raycasting to get the normal of the terrain hit by the ray. This normal is in world space, with the point of the terrain hit by the ray as origin (correct me if I'm wrong). In case I transform this normal in local space with Transform.InverseTransformDirection, which is the origin of the normal ? In which case is it relevant to make this transformation ?
Thanks
you could do some testing and debugging to see what is happening.
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit,))
{
Debug.Log ("origin " + ray.origin + " : hit point " + hit.point + " : hit normal " + hit.normal);
Debug.DrawLine (ray.origin, hit.point);
}
there might be more information in the docs :
http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit-point.html
http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit-normal.html
http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
http://docs.unity3d.com/Documentation/ScriptReference/Debug.DrawLine.html
Edit : sry, should've included that.