コード例 #1
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "ProjectileEnemy")
     {
         float dmg = col.gameObject.GetComponentInParent <ProjectileSpawnEnemy>().GetProjectileDamage();
         gameControl.DamagePlayer(dmg);
         gameControl.PlayAudioClip(explosion);
         GameObject effect = Instantiate(explode, col.transform.position, Quaternion.identity);
         Destroy(effect, 3f);
         Destroy(col.transform.parent.gameObject);
     }
 }
コード例 #2
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Player")
     {
         NpcDeathEffect();
         gameControl.DamagePlayer(npcDamage);
         gameControl.AddPoints(npcSpeed);
         Destroy(this.gameObject, 0.1f); // added this small amount of time makes such a difference
     }
     else if (col.gameObject.tag == "Projectile")
     {
         gameControl.DamageNPC(this.gameObject, npcPoints, gameControl.GetPlayerDamage(), ref npcHealth);
         Destroy(col.transform.parent.gameObject);
     }
 }