Search Unity

Simple Programming Question

Discussion in 'Scripting' started by keenanwoodall, Sep 22, 2014.

  1. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    I"m getting this error and really don't know why!

    Assets/Scripts/Player/ItemPickUp.js(9,18): BCE0031: Language feature not implemented: Ambiguous(ItemPickUp.collider, UnityEngine.Component.collider).

    Code (js):
    1.  
    2. @script RequireComponent(BoxCollider);
    3.  
    4. var pickUpDistance : float = 3.0;
    5.  
    6. private var collider : BoxCollider;
    7.  
    8. function Start ()
    9. {
    10.     collider = this.gameObject.GetComponent(BoxCollider);
    11. }
    12.  
    13. function Update ()
    14. {
    15.  
    16. }
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Component (which your script is one of, through MonoBehaviour) already has a variable named 'collider' (it's a convenience property that acts as a shortcut for 'GetComponent(Collider)'. ) You've created your own variable named 'collider'. There are now two things named 'collider' in your object, and so when you try to assign to it, the compiler doesn't know which one you mean.

    Short answer: Rename your variable.
     
  3. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    Thanks a bunch. It works perfectly now!
     
  4. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Strange. US doesn't support member hiding?