ExplosiveAmmo
The ExplosiveAmmo
script extends ProjectileAmmo
to include splash damage using a configurable radius and falloff curve.
Summary
This component:
- Applies area-of-effect (AOE) damage on impact
- Scales damage based on distance using a falloff curve
- Can hit multiple targets
Fields
Field | Type | Description |
---|---|---|
range | float | Radius of the explosion (default: 5). |
falloffNormalized | AnimationCurve | Curve to scale damage based on distance from explosion center. X = distance %, Y = damage multiplier. |
Inherited Fields
See ProjectileAmmo
for fields like _speed
, _lifetime
, and OnImpact
.
Collision Behavior
- On impact:
- Checks all colliders in range with
Physics.OverlapSphere
- Calculates damage using the falloff curve
- Applies scaled damage to each
Hitbox
- Fires the
OnImpact
event - Destroys the projectile
- Checks all colliders in range with
Example Falloff Curve
Normalized Distance | Damage Multiplier |
---|---|
0.0 | 1.0 |
0.5 | 0.5 |
1.0 | 0.0 |
Tip
Use this for grenades, rockets, or energy blasts.
Warning
Be mindful of performance when using Physics.OverlapSphere
on many projectiles.