コード例 #1
0
ファイル: DamageOnStay.cs プロジェクト: CellPot/DemoShooter
        private void OnTriggerStay(Collider other)
        {
            var otherHealth = other.gameObject.GetComponent <Health>();

            if (otherHealth != null)
            {
                _damageOnContact.Damage(damageInflicted, otherHealth);
            }
        }
コード例 #2
0
        private void OnTriggerEnter(Collider other)
        {
            var otherHealth = other.gameObject.GetComponent <Health>();

            if (otherHealth != null)
            {
                _damageOnContact.Damage(DamageInflicted, otherHealth);
            }
            gameObject.SetActive(false);
        }
コード例 #3
0
        private void OnCollisionEnter(Collision other)
        {
            Health otherHealth = other.gameObject.GetComponent <Health>();

            if (otherHealth != null)
            {
                _damageOnContact.Damage(DamageInflicted, otherHealth);
                // Debug.Log($"{otherHealth.gameObject}'s health: {otherHealth.HealthValue}/{otherHealth.MaxHealthValue}");
            }
            gameObject.SetActive(false);
        }