collider and raycast question

Hi,

if I have the following

var myTest : GameObject;

and do the following

var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay( Input.mousePosition );
if ( myTest.collider.Raycast( ray, hit, Mathf.Infinity) )
{
Debug.Log( “HIT HIT” );
}

I get the following error:

MissingMethodException: Method not found: ‘UnityEngine.MeshCollider.Raycast’.

the documentation says the Raycast is there?

anyone?

Peter

I think there’s a bug with Collider.Raycast in UnityScript for some reason, you need to use #pragma strict to get it to work.

If you look at the docs example here you’ll see it there at the top.

Hi,

won’t the #pragma strict force me to define types for all my variables (I know that is good)… but…

anyways I found a solution, doing a (myTest.collider as MeshCollider).Raycast works… and yes it looks like it’s a bug!
wasted many hours on this :frowning:

Peter