Raycast Normal problems?

I can’t for the life of me figure this out.

All I want is to obtain the surface normal of a plane that I target. No matter what I seem to do, it never seems to give me the proper normal back.

I use a RaycastHit to store the out from the raycast, and it’s a simple raycast, From camera transform position, in camera.transform.forward direction…

When the raycast succeeds, I simply do a Debug.Drawline from rayhit.point in rayhit.normal direction. The object that I’m hitting has NO apparent bearing on what direction the normal gives back, and the normal direction returned is clearly not the normal of the targetted plane… I simply don’t even know where to begin debugging this, as. Also, when I do a debug log on the object that it hit, it IS colliding with the proper target that I expect it to hit… but again, the .normal is just totally screwy.

I’ve been trying to figure this for about a week now.

I can’t understand if this is something I’m doing wrong, or something wrong with the engine itself.

Has anyone else experienced whackiness with the unity normals as well, or is the general consensus going to be that I’m doing something wrong.

Any help is useful, as I’ve been stuck on this seemingly easy problem for way longer than I care to be.

Some code would help.

–Eric

var rayhit : RaycastHit;

if(Physics.Raycast(camera.transform.position, camera.transform.forward, rayhit, 5.0, layerMask))
{
	Debug.DrawLine(rayhit.transform.position, rayhit.normal, Color.green);
}

As an illustration… the Green line is what is rendered as the “Normal” from the above code, when it seems obvious to me that the normal should closer resemble the RED line (Hand drew in paint)

Some things: DrawLine takes two positions; DrawRay is what you would use here. You can just use rayhit.point rather than rayhit.transform.position. You can leave out “camera” when doing “Raycast(transform.position, transform.forward”, since you don’t care about the camera when doing that (only the transform), assuming “camera” refers to the attached camera component and isn’t a variable.

–Eric