mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 01:21:07 +00:00
la bombe tu maintenant l'ennemi
la bombe tue les enemies qui ce trouve dans son rayon d'explosion et sur le layer enemies
This commit is contained in:
parent
c19bf50e2f
commit
354821e715
@ -47,7 +47,7 @@ public class Bomb : MonoBehaviour
|
|||||||
layBombs.bombLaid = false;
|
layBombs.bombLaid = false;
|
||||||
|
|
||||||
// Find all the colliders on the Enemies layer within the bombRadius.
|
// Find all the colliders on the Enemies layer within the bombRadius.
|
||||||
Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemy"));
|
Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemies"));
|
||||||
|
|
||||||
// For each collider...
|
// For each collider...
|
||||||
foreach(Collider2D col in enemies)
|
foreach(Collider2D col in enemies)
|
||||||
@ -58,13 +58,6 @@ public class Bomb : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// Find the Enemy script and set the enemy's health to zero.
|
// Find the Enemy script and set the enemy's health to zero.
|
||||||
rb.gameObject.GetComponent<Health>().removeHP(1000);
|
rb.gameObject.GetComponent<Health>().removeHP(1000);
|
||||||
|
|
||||||
// Find a vector from the bomb to the enemy.
|
|
||||||
Vector3 deltaPos = rb.transform.position - transform.position;
|
|
||||||
|
|
||||||
// Apply a force in this direction with a magnitude of bombForce.
|
|
||||||
Vector3 force = deltaPos.normalized * bombForce;
|
|
||||||
rb.AddForce(force);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user