MDamageable

โœ”

Overview

This component is in charge of connecting the Animal Controller to any Damager Component. This will receive the Direction, Stat to modify and it will make an Animal Reaction accordingly to the Damager information

This Component Requires a reference to the Stats Component

This component can be also used on child colliders to simulate specific damages.

E.g.

  • You can add a MDamageable Component to the Head collider, and add a Multiplier of 2 to simulate Headshots that make twice the damage value.

  • You can add a MDamageable Component to the Chest collider, Shield, or Head Helmet, add a Multiplier of 0.5 to simulate Defense, and only do half the Damage.

Internal MDamageables

The component can also be set inside the Animal Hierarchy. This is very useful to create different damages and reactions to the animal.

For example, you can add an MDamageable component to the Head Collider, with a multiplier of 2 and a Reaction set to Play the Stun Action for 3 Seconds. If the Animal receives direct damage to the head collider, the Damage value will double and it will play a stun animation instead of the Damage Animations.

Parameters

General

Root

The root Damageable gameobject, if this is a child gameobject

Surface

Type of surface the damageable is e.g. Wood, Flesh, Metal etc.

Default Reaction

Reaction to apply on the Animal when receiving Damage. By Default it will apply Mode Damage on the Animal. but you can change it and use any other Animal Reaction.

You can add a MDamageable Component to the Head collider and change the reaction to activate a Stun Animation instead.

Critical Reaction

The reaction to apply to the animal if a critical hit is achieved.

Damager Reaction

The reaction to apply to the animal that is dealing the damage to this gameobject

Ignore Damager Reaction

This damageable will ignore the reaction coming from the damager. Use this when the damager needs to use the default reaction

Stats

Reference to the Stats component

Multiplier

Value to apply an extra modification to the Stats to make Double Damage, if is set to greater than 1; or acts as Defense value if is set to a value between 0-1.

Elements

A list of elements (Fire, Ice, Rock, Lightning etc.) and their associated damage multipliers that affect the damage values given to this gameobject.

Align to Damage

When enabled the animal will rotate toward the damage direction

Align Time

How long the alignment will last

Align Curve

Curve to smooth the trajectory of the alignment

Align Offset

For Animals in which the pivot may be set in the Hip position you can adjust the Rotation Pivot of the alignment with this value:

Profiles

To Activate a profile, call this function:

MDamageable.Profile_Set(string profileName)

To reset to the default values, call:

MDamageable.Profile_Restore();

The damageable can use different profiles to change the way the animal can react to receiving damage.

E.g. You can activate a Profile when the Character has a New Armor, and it changes the way the Damage is done. So the character will receive half the damage.

Or you can change the Profile to Heavy Damage Animations if the Animal is in a Wounded stance.

Name

The name of the profile

All the parameters inside a profile are the same parameters on the MDamageable.

Events

On Receiving Damage (Float)

Invoked when the Damageable receives damage. Sends the final value of the Stat modification.

On Critical Damage

Invoked if the Damage received is Critical.

On Damager (Gameobject)

This is invoked when a Damage is received. Use it to know who did the Damage.

On Element Damage (Int)

Invoked when receiving elemental damage (Wood, Fire, Ice, Electric etc).

Last updated