#pragma strict problem?

#pragma strict

function OnCollisionStay (collision : Collision)
{
	if (collision.gameObject.tag == "Foo")
	{
		// snip
	}
}

Produces error: error BCE0019: ‘tag’ is not a member of ‘System.Object’.

Am I doing this wrong, or what? Thought I’d give JavaScript another try. :confused:

Thanks!
-Jon

#pragma strict

function OnCollisionStay (collision : Collision)
{
	var collisionObject : GameObject = collision.gameObject;
	if (collisionObject.tag == "Foo")
	{
		// snip
	}
}

If you get errors with #pragma strict, then you have to explicitly define the type.

–Eric

But Collision.gameObject is already explicitly defined as GameObject. And adding lines like that take away what using JavaScript over C# gives: brevity.

-Jon

It’s only in a few cases where the type inference doesn’t seem to work; OTEE guys can explain it since I don’t really know what I’m talking about. :slight_smile: And of course you don’t have to use #pragma strict. That only prevents dynamic typing from ever occuring, and most of the time it doesn’t occur anyway.

–Eric