- Home /
android version of game shows error
here is my code, which is runs in PC version. now I'm making its android part.but following codes show some error. what may b the reason?
var hit:ControllerColliderHit;
function OnControllerColliderHit(hit)
{
if(hit.collider.gameObject.tag=="level1")
{
//do something;
}
}
It shows this error:
Assets/tornado/scripts/point_monitor.js(27,24): BCE0019: 'collider' is not a member of 'Object'.
You will need to be more clear on what is ControllerColliderHit is.. collider is a GameObject component
thank you SolidSnake. I'm using a character controller. from the following doc "http://docs.unity3d.com/Documentation/ScriptReference/ControllerColliderHit.html" i can understand that it is related to character controller.
which point i should take care.. as long as am a newbie i don't understand were I'm went wrong?
I see... seems that Unity thinks hit is of the generic type "Object" try to cast hit.. something like (hit as ControllerColliderHit).collider
actually sorry... I noticed that your function decleration is wrong.. it should be :
function OnControllerColliderHit(hit: ControllerColliderHit)
check example:
Answer by Loius · Oct 23, 2012 at 12:35 PM
When working with Android and Unity-javascript, you need to include "#pragma strict" at the top of your scripts. Any errors that detects/causes will also show up as errors on the Android device. Pragma strict disables Javascript's lazy-typing, which isn't supported on Android.
Your answer
