Checked with version: 2017.3
The damage system in the kit is composed of two components: Damager and Damageable scripts.
Adding a Damager script to an object makes it able to inflict damage to any object that has a Damageable component, as long as their settings match.
The Damager Component has events for collision with Damageable components and non Damageable components. The health calculation is done automatically and these events are used for triggering gameplay changes or visual effects.
The Damager component does not require a collider, it will display a box gizmo in the Scene View you can use to tweak its size and position.
Damage: The amount of damage it will inflict on a Damageable (e.g Ellen or Chomper) when hit.
Offset and Size: these are the two parameters that define the Damager collision box. This is the outer box displayed on the Spikes in the Scene View as the outer box, it will inflict damage when this is collided with.
Offset Based On Sprite Facing: This setting allows the Damager to change position based on which direction a sprite is facing. E.g. This is used on Ellen allowing the Damager to lip left and right depending on which way she is facing.
Sprite Renderer: The Sprite Renderer that the above setting uses.
Can Hit Triggers: Toggles whether the Damager will collide with triggers if checked or totally ignore triggers if unchecked.
Force Respawn: If this is enabled, the object containing a Damageable will immediately respawn to the latest checkpoint ( the Acid prefab uses this when the player falls into the water).
Ignore Invincibility: If enabled, the Damager will still register a ‘hit’ to the Damageable but not remove health (the Acid uses this so that the player will always respawn even if they are invincible from a previous enemy hit).
Hittable Layers: The Layers which the Damager will inflict damage. Layers that are not selected will not receive damage.
On Damageable Hit: Events here will play when the object is hit and it has a Damageable component.
On Non Damageable Hit: Events here will play when the object is hit but does not have a Damageable component.
The Damageable Component receives damage from collisions of objects with the Damager Component attached to them. There are events for when damage is received, health is restored, health changes, or complete depletion of health (death) occurs.
Contrary to the Damager, the Damageable component relies on colliders attached to the same GameObject, so in addition to adding a Damageable Script to your object, don't forget to add colliders to define hittable zones.
Starting Health: Health level. Damagers will remove their health at each impact. Damageables die when this reaches 0.
Invulnerable After Damage: This Damageable becomes invulnerable for a given time after impact.
Invulnerability Duration: Length of time (in seconds) that this Damageable is considered invulnerable after impact (only applicable if previous setting is set).
Disable On Death: This setting will disable the GameObject on death.
Center Offset: This is used to define where the centre of the Damageable is (an offset of (0,0,0) means it is on the GameObject position). Used to compute distance to Damager.
On Take Damage: Events triggered when the object receives damage.
On Die: Events triggered when the object** **
On Gain Health: Events triggered when an object gains new health.
Persistent Type: See Persistent Data
Data Tag: See Persistent Data
Checkpoints are found in the folder Prefabs < SceneControl
Each time the Player enters a checkpoint collider, this checkpoint becomes active. When they fall into the water (or get hit by any Damager that has the Force Respawn setting) they will reappear at that checkpoint.
Note: The Player will reappear at the GameObject position, so make sure it is above ground.