Search Unity

Re-spawn Bot Health to Public int Health

Discussion in 'Scripting' started by jonkuze, Jan 28, 2013.

  1. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    when using "C# Instantiate", to re-spawn an enemy bot, how do i make the health of that re-spawned bot to be equal to what I set for "public int health = 18;" in the Inspector ?


    currently at the end of my Instantiate line of code i have something like this... "gi.GetComponent<MineBotAI>().health = 18;" but that forces the bot to have 18 health, not exactly what is set in the "public int health = 18" (if i change it in the inspector)

    is there something I can put in place of 18 in my Instantiate Line of Code such as .health = (same as int) ??
     
  2. SkaredCreations

    SkaredCreations

    Joined:
    Sep 29, 2010
    Posts:
    296
    If you are using Instantiate from a prefab you don't need to set this variable since it is already set in the prefab.