コード例 #1
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Player")
     {
         gameControl.AddPoints(pointValue);
         gameControl.PlayAudioClip(clip);
     }
     Destroy(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);
     }
 }