Search Unity

enemy scripts

Discussion in 'Scripting' started by Exodo98, Apr 17, 2014.

  1. Exodo98

    Exodo98

    Joined:
    Apr 13, 2014
    Posts:
    2
    I have two Scrpits placed in my enemies, and one of them take a "isDead" boolean from the other to check is alive.
    The thins is, when one of the enemies is died, the other take the boolean as true too.

    Can i call a specific script? What can i do to solve it?

    Thank you!
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
  3. ZenDelta

    ZenDelta

    Joined:
    Feb 23, 2013
    Posts:
    2
    I would made it in one script becuase I find it much more simpler that way where you just can refer to the bool. What you could do is make the bool static by
    PHP:
    static public bool isDead false
    in the other script.. Then you can access it in the other by

    PHP:
    theotherscript.isdead;
    It's how I would done it if I use two scripts :]
     
  4. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Making it static would only work if there was a total of 1 enemy at any time, since the isDead variable would hold the same value for every single instance of the script.