// Update is called once per frame public void Hurt(int damage) { _health -= damage; Debug.Log(" health: " + _health); if (_health <= 0) { float timetakea = Time.realtimeSinceStartup; timetake = Mathf.Round(timetakea); GameObject gun = GameObject.Find("Main Camera"); float tiltAroundZ = Input.GetAxis("Horizontal") * 90; Quaternion target = Quaternion.Euler(0, 0, tiltAroundZ); gunfromcamera guun = gun.GetComponent <gunfromcamera>(); endtext.text = "YOU DIED!!! you last " + timetake + " seconds and killed " + kills + " ghosts."; soundSource.PlayOneShot(death); StartCoroutine(Die()); _health = 0; playermove status = GetComponent <playermove>(); wanderAI behavior = GetComponent <wanderAI>(); chargerAI behaviora = GetComponent <chargerAI>(); if (status != null) { status.SetAlivep(false); } if (behavior != null) { behavior.SetAlive(false); } if (behaviora != null) { behaviora.SetAlive(false); } } }
// Use this for initialization public void ReactToHit() { wanderAI behavior = GetComponent <wanderAI>(); chargerAI behaviora = GetComponent <chargerAI>(); playerchara player = GetComponent <playerchara>(); StartCoroutine(Die()); soundSource.PlayOneShot(death); if (behavior != null) { behavior.SetAlive(false); if (behavior._alive) { player.kills += 1; } } if (behaviora != null) { behaviora.SetAlive(false); if (behaviora._aalive) { player.kills += 1; } } }