The Explosion component is a relatively simple component which will apply a force and damage to any nearby Rigidbodies or objects with the Health component attached. When it is spawned it can optionally explode immediately or wait for the Explode method to be called.
An explosion can be setup by performing the following:
- Open the Object Manager and create a new object of type Explosion.
- Specify the material used by the Particle System.
- Optionally add an AudioSource if the explosion should play an audio clip when it explodes.
- Assign the prefab to the object that should cause the explosion. As an example it can be assigned to the Frag Grenade under the Spawned Objects on Destruction foldout:
Explode On Enable
Should the object explode when the object is enabled?
Determines how far out the explosion affects other objects.The magnitude of the force and damage will be scaled based on the distance that the object was hit – the further from the explosion the less force/damage the object will receive.
The maximum amount of damage to explosion applies to objects with the Health component.
The maximum amount of force the explosion applies to nearby Rigidbody/IForceObject objects.
The layers that the explosion can affect.
Line Of Sight
Does the explosion require line of sight in order to damage the hit object
The duration of the explosion.
Max Collision Count
The maximum number of objects that the explosions can detect.
Explosion Audio Clip Set
A set of AudioClips that can be played when the explosion occurs. The AudioClip that is played will randomly be selected out of this list.