- Home /
RaycastHit.normal problem
No matter what surface I'm on RaycastHit.normal.y always reads 1. From my understanding it should read somewhere between 0-1 depending on the surface.
Here's some of my code. Thanks in advance.
RaycastHit hitInfo;
if(Physics.Raycast(transform.position + Vector3.up, Vector3.down, out hitInfo))
{
if(hitInfo.normal.y < SlideThreshold)
{
SlideDirection = new Vector3(hitInfo.normal.x, -hitInfo.normal.y, hitInfo.normal.z);
}
}
Hey I'm having a same problem here. have you found solution yet?
Are you having only objects that are orthogonal or parallel to the axes?
Did you check where the ray is hitting? I'm using plenty of rays in a level design system and I just tilted some objects to see the results and it is working properly. I'm using javascript, but this is not the issue, I suppose. Try to Debug.Log() the y value and the hit.transform.name in case you didn't already.
It's hit.point, it will return a vector3. http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit-point.html