How do I return local normals?

I’m using a raycast to return the normal of the surface it hits, but I understand that it’s in world coordinates. If I rotate the cube and fire the raycast at the same face, it returns a different value.

Is there a way to return normals in the local coordinates of the object? I’m sorry if the wording in this question is a little confusing.


The script I’m working on:

private var ray : Ray;
private var hit : RaycastHit;

var localNormal : Vector3;

function Update ()


	ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	if (Physics.Raycast (ray, hit)) 

			var localNormal = hit.transform.InverseTransformDirection(hit.normal);
			transform.position = hit.point;       

You can convert the normal to local coordinates with transform.InverseTransformDirection. Supposing hit is the RaycastHit used in Raycast, you can do the following:

var localNormal = hit.transform.InverseTransformDirection(hit.normal);