void Start() { //Initializing the plague and hp scripts for reference anim = Character.GetComponent <Animator>(); plagueScript = Character.GetComponent <PlagueBolt>(); hpScript = Character.GetComponent <HpScript>(); }
// Start is called before the first frame update void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); } playerHp = GameObject.FindGameObjectWithTag("Player").GetComponent <HpScript>(); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Wall")) { Destroy(gameObject); } if (collision.gameObject.CompareTag("Enemy")) { //randomizar o valor para instanciar o damageFx - remove o parent e muda sua escala para destruir int randomIndex = Random.Range(0, damageFx.Count - 1); GameObject damageFxClone = Instantiate(damageFx[randomIndex], this.transform); damageFxClone.transform.SetParent(null); damageFxClone.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); Destroy(damageFxClone, 0.3f); //checa se o inimigo tem o script HPScript para diminuir hp e depois destruir HpScript hpScript = collision.gameObject.GetComponent <HpScript>(); if (hpScript) { hpScript.RemoveHp(damage); } Destroy(gameObject); } }
// Start is called before the first frame update void Start() { hpScript = GetComponent <HpScript>(); hpSlider.minValue = 0; hpSlider.maxValue = hpScript.Hp; }
void Start() { playerHp = GameObject.FindGameObjectWithTag("Player").GetComponent <HpScript>(); }