Search Unity

script for deactivated activated game object

Discussion in 'Scripting' started by Infektado, Aug 31, 2014.

  1. Infektado

    Infektado

    Joined:
    Aug 3, 2013
    Posts:
    11
    Code (JavaScript):
    1. var tripa : GameObject;
    2. var toque : boolean = false;
    3.  
    4. tripa.active = false;
    5.  
    6. function OnMouseDown() {
    7.      if (!toque) {
    8.  
    9. tripa.active = true;
    10.         }
    11. }
    I've been attached this script to another object for deactivated on start game & activate especific game objects, but only deactivate, when I clicked on it nothig happens, what's wrong?
    I am newbie in java & C#
    Thanks.
     
  2. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    You are not calling the right method thats all. Try:
    tripa.SetActive(false);

    Hope this helps.
     
  3. Infektado

    Infektado

    Joined:
    Aug 3, 2013
    Posts:
    11
    It works like a charm! ;)
    Thanks!!!
     
    Polymorphik likes this.
  4. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    No problem.