Beispiel #1
0
    public override void Collision(RaycastHit hit)
    {
        Rigidbody rb = hit.rigidbody;

        if (rb != null)
        {
            rb.AddForceAtPosition(bullet.inpulseForce * transform.forward, hit.point, ForceMode.Impulse);
        }
        HealthManagementScript hm = hit.transform.GetComponent <HealthManagementScript> ();

        if (hm != null)
        {
            hm.ApplyDamage(bullet.damage);
        }

        Destroy(gameObject);
    }
Beispiel #2
0
 public override void Collision(RaycastHit hit)
 {
     Destroy(Instantiate(bullet.explosionPrefab, hit.point, transform.rotation), 1.0f);
     foreach (Collider item in Physics.OverlapSphere(hit.point, bullet.explosionRadius))
     {
         Rigidbody rb = item.GetComponent <Rigidbody> ();
         if (rb != null)
         {
             rb.AddExplosionForce(bullet.explosionForce, hit.point, bullet.explosionRadius);
         }
         HealthManagementScript hm = item.GetComponent <HealthManagementScript> ();
         if (hm != null)
         {
             hm.ApplyDamage(bullet.damage);
         }
     }
     Destroy(gameObject);
 }