Setting Up Weapons Damage
The Health Modifier component enables you to create all kinds of weapons using this kit. This component has a range of different functions you can call to cause damage.

Causing Damage

This kit uses raycasts to enable accurate detection of collisions between fast-moving projectiles and objects of all sizes.
When you use Unity's Physics.Raycast API, it returns a RaycastHit struct, which has information about the collider that was hit, the position of the hit, etc. This can be passed directly to the Health Modifier component through the RaycastHitDamage or RaycastHitAreaDamage functions, whereupon the Health Modifier will damage the object that was hit by the raycast depending on how its settings have been set up.
To enable raycast collision checks without writing code, this kit has a CollisionScanner component that can be added to a projectile, which scans for collisions each frame. In the On Hit Detected event, you can add the appropriate Health Modifier function that you want to be called when a hit is detected.
The EmitDamage function can be called to cause area damage from current position.

Area Damage

Sometimes you might want a weapon such as a missile to cause damage to everything in a specified radius.
To cause area damage, an object must have a Rigidbody, a DamageReceiverScanner component on the root transform, and a trigger collider of some kind in its hierarchy.
Drag the DamageReceiverScanner into the 'Damage Receiver Scanner' field in the inspector of the Health Modifier component.
This enables it to store information about Damage Receivers in the vicinity and cause damage to them based on their distance.
You can set the damage falloff (based on distance) with an animation curve, by setting the 'Damage Falloff Curve' in the inspector of the Health Modifier component.
Copy link