コード例 #1
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "Player")
            {
                PlayerHealth playerHealth = other.GetComponent <PlayerHealth> ();

                if (playerHealth != null)
                {
                    playerHealth.TakeDamage(damage);
                }

                KnockbackOnHit knockback = other.GetComponent <KnockbackOnHit> ();

                if (knockback != null)
                {
                    knockback.knockbackFromRight = JVUtil.IsTargetOnTheLeft(other.transform, transform);
                }
            }
        }
コード例 #2
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "Enemy")
            {
                //Instantiate (enemyDeathEffect, other.transform.position, other.transform.rotation);
                //Destroy (other.gameObject);
                //ScoreManager.AddPoints (pointsForKill);

                other.GetComponent <Health> ().TakeDamage(damage);

                KnockbackOnHit knockback = other.GetComponent <KnockbackOnHit> ();

                if (knockback != null)
                {
                    knockback.knockbackFromRight = JVUtil.IsTargetOnTheLeft(other.transform, transform);
                }
            }

            SelfDestroy();
        }