Player Explosion
Built-in Player Explosion Parts
The following objects are involved in the player entity explosion: Vehicle, Wheels, Turrets, Armors, Rockets.
For the system to work correctly, the following requirements must be met:
Each object must be assigned to the PlayerPart layer
Each object must have either the ExplosionPart or ExplosionEffectHandler script attached
What is the difference between ExplosionPart and ExplosionEffectHandler?
ExplosionPart and ExplosionEffectHandler?ExplosionPart is used for parts that are affected by upgrade levels. Each upgrade level may have a different visual representation of the part during the explosion.
ExplosionPart works together with the PartLevelController component, which provides information about the currently active upgrade level of the part.
Example:
Wheels use ExplosionPart because they support 4 upgrade levels, each with its own visual variation.

ExplosionEffectHandler handles parts that are not affected by upgrade levels and always use a single visual representation.
Example:
The vehicle body uses ExplosionEffectHandler because it does not have upgrade levels.

Configuring the parts scatter zone during explosion
The parameters for parts scattering after the player’s death are configured through the FragmentExplosion config.
Path: Assets/StaticAssets/Configs/FragmentExplosion
When the PlayerGraphics object is selected in the scene, the boundaries of the scatter zone are displayed — this helps visually control the effect’s area of influence.
The ShowTrajectory button is used to display flight trajectories:
Activates visualization of the expected movement directions of parts;
Useful for adjusting scatter angles.

For correct parts scattering functionality, ensure that all part objects are on the PlayerPart layer.
When changing the layer, be sure to select "Yes, change children" so the layer applies to all nested objects.

How to Add a New Explosion Part
Open the PlayerGraphics prefab.
Create two GameObjects:
A parent object named New Part Holder
A child object (for example, a cube) named New Part

In this example, New Part exists as a single instance and does not depend on upgrade levels. Therefore, add the
ExplosionEffectHandlercomponent to New Part Holder.The New Part object must contain the following components:
MeshRendererAny
ColliderRigidbody
In the Rigidbody component, make sure Is Kinematic is set to true.

Assign the PlayerPart layer to New Part Holder.
When changing the layer, be sure to select "Yes, change children" so the layer applies to all nested objects.
In the ExplosionEffectHandler component on New Part Holder, assign all required references.

After completing these steps, the cube will be detached and thrown away when the player explodes.


Last updated