Hi! I’m trying to use the raycast but when striking the object appears this message:
Field ‘UnityEngine.RaycastHit.Collider’ not found.
The code:
var Range = 10;
function Update()
{
var hit : RaycastHit;
var fwd : Vector3 = transform.TransformDirection(Vector3.forward);
Debug.DrawRay(transform.position, fwd, Color.green);
if (Physics.Raycast(transform.position, fwd, hit, Range))
{
if (hit.Collider.gameObject == "tree")
{
Debug.Log("Ok");
}
}
else
{
Debug.Log("No");
}
}
Just a simple code that allowed me to show the log message when the camera get the object. But this error message doesn’t make it works correctly. What can be this error?