Search Unity

Alt for gameObject when using pragma strict?

Discussion in 'Android' started by tecra134, Jun 29, 2012.

  1. tecra134

    tecra134

    Joined:
    Mar 19, 2011
    Posts:
    94
    The code I'm running is:

    Code (csharp):
    1.  
    2. function OnCollisionEnter(other)
    3. {
    4. if(other.gameObject.name = blah blah blah)
    5. {
    6. do something
    7. }
    8. }
    9.  
    When I check this with the pragma strict enabled, I get an error telling me "gameObject" isn't a member of Object. What is the alternate to this?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    All variables must have their type defined, either explicitly or by supplying a value. In this case it has to be explicit.

    Code (csharp):
    1. function OnCollisionEnter(other : Collision)
    --Eric
     
  3. tecra134

    tecra134

    Joined:
    Mar 19, 2011
    Posts:
    94
    Ahhh. Thanks!