Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

how do i activate a gameobject?

Discussion in 'Scripting' started by Warp boy2, Dec 20, 2010.

  1. Warp boy2

    Warp boy2

    Joined:
    Nov 12, 2010
    Posts:
    216
    well.. i unchecked that box in the inspector



    and i made a script like this

    Code (csharp):
    1.  
    2.  
    3. function Update () {
    4.  
    5. if (Input.GetButtonDown ("shoot")) {
    6.  
    7. GameObject.Find("NEWPOINT").active = true;
    8.  
    9. }
    10. }
    11.  
    12.  
    but i doest not work.. am i doing something wrong?
     
  2. pakfront

    pakfront

    Joined:
    Oct 6, 2010
    Posts:
    551
  3. Warp boy2

    Warp boy2

    Joined:
    Nov 12, 2010
    Posts:
    216
    so the gameObject.Find only finds active objects.. and thats why is not fidning the NEWPOINT because he is unchecked..

    damm...
     
  4. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    You can still activate the object, just get a reference to the object a different way (such as assigning it in the inspector).

    Code (csharp):
    1. var target : GameObject;
    2.  
    3. function Update (){
    4.     if (Input.GetButtonDown("Jump")) target.active = true;
    5. }