private void OnParticleCollision(GameObject other) { if (other.GetComponent <PlayerController>()) { return; } if (health.GetHealth() <= 0) { Destroy(gameObject); GameObject deathVFX = Instantiate(deathExplosion, transform.position, Quaternion.identity) as GameObject; deathVFX.transform.parent = parent; Destroy(deathVFX, 1.5f); scoreHandler.AddToScore(score); } health.DealDamage(player.GetBulletDamage()); }
private void Update() { if (networkObject.IsOwner) { // If we are the owner of the object we should send the new position // and rotation across the network for receivers to move to in the above code networkObject.position = transform.position; networkObject.rotation = transform.rotation; networkObject.isDead = m_aiMonster.IsDead; networkObject.health = m_healthHandler.GetHealth(); } else { transform.position = networkObject.position; transform.rotation = networkObject.rotation; if (networkObject.isDead) { m_aiMonster.OnDeath(); } m_healthHandler.SetHealth(networkObject.health); } }
// Update is called once per frame void Update() { healthDisplay.text = health.GetHealth().ToString(); }
private void OnCollisionEnter(Collision collision) { health.ReduceHealth(health.GetHealth()); }
private void Start() { m_HealthBar.fillAmount = 1.0f; m_HealthText.text = (int)m_PlayerHealth.GetHealth() + " / " + (int)m_PlayerHealth.GetMaxHealth(); }