![]() |
TopDown Engine v4.3
|
Add this component to an object and it will cause damage to objects that collide with it. More...
Public Types | |
enum | TriggerAndCollisionMask { IgnoreAll = 0 , OnTriggerEnter = 1 << 0 , OnTriggerStay = 1 << 1 , OnTriggerEnter2D = 1 << 6 , OnTriggerStay2D = 1 << 7 , All_3D = OnTriggerEnter | OnTriggerStay , All_2D = OnTriggerEnter2D | OnTriggerStay2D , All = All_3D | All_2D } |
enum | KnockbackStyles { NoKnockback , AddForce } |
the possible ways to add knockback : noKnockback, which won't do nothing, set force, or add force More... | |
enum | KnockbackDirections { BasedOnOwnerPosition , BasedOnSpeed , BasedOnDirection , BasedOnScriptDirection } |
the possible knockback directions More... | |
enum | DamageDirections { BasedOnOwnerPosition , BasedOnVelocity , BasedOnScriptDirection } |
the possible ways to determine damage directions More... | |
Public Member Functions | |
virtual void | Initialization () |
Initializes ignore list, feedbacks, colliders and grabs components More... | |
virtual void | InitializeFeedbacks () |
Initializes feedbacks More... | |
virtual void | SetGizmoSize (Vector3 newGizmoSize) |
A public method letting you (re)define gizmo size More... | |
virtual void | SetGizmoOffset (Vector3 newOffset) |
A public method letting you specify a gizmo offset More... | |
virtual void | SetKnockbackScriptDirection (Vector3 newDirection) |
When knockback is in script direction mode, lets you specify the direction of the knockback More... | |
virtual void | SetDamageScriptDirection (Vector3 newDirection) |
When damage direction is in script mode, lets you specify the direction of damage More... | |
virtual void | IgnoreGameObject (GameObject newIgnoredGameObject) |
Adds the gameobject set in parameters to the ignore list More... | |
virtual void | StopIgnoringObject (GameObject ignoredGameObject) |
Removes the object set in parameters from the ignore list More... | |
virtual void | ClearIgnoreList () |
Clears the ignore list. More... | |
virtual void | OnTriggerStay2D (Collider2D collider) |
When a collision with the player is triggered, we give damage to the player and knock it back More... | |
virtual void | OnTriggerEnter2D (Collider2D collider) |
On trigger enter 2D, we call our colliding endpoint More... | |
virtual void | OnTriggerStay (Collider collider) |
On trigger stay, we call our colliding endpoint More... | |
virtual void | OnTriggerEnter (Collider collider) |
On trigger enter, we call our colliding endpoint More... | |
Public Attributes | |
LayerMask | TargetLayerMask |
the layers that will be damaged by this object More... | |
GameObject | Owner |
the owner of the DamageOnTouch zone More... | |
TriggerAndCollisionMask | TriggerFilter = AllowedTriggerCallbacks |
Defines on what triggers the damage should be applied, by default on enter and stay (both 2D and 3D) but this field will let you exclude triggers if needed. More... | |
float | MinDamageCaused = 10f |
The min amount of health to remove from the player's health. More... | |
float | MaxDamageCaused = 10f |
The max amount of health to remove from the player's health. More... | |
List< TypedDamage > | TypedDamages |
a list of typed damage definitions that will be applied on top of the base damage More... | |
DamageDirections | DamageDirectionMode = DamageDirections.BasedOnVelocity |
how to determine the damage direction passed to the Health damage method, usually you'll use velocity for moving damage areas (projectiles) and owner position for melee weapons More... | |
KnockbackStyles | DamageCausedKnockbackType = KnockbackStyles.AddForce |
the type of knockback to apply when causing damage More... | |
KnockbackDirections | DamageCausedKnockbackDirection = KnockbackDirections.BasedOnOwnerPosition |
The direction to apply the knockback. More... | |
Vector3 | DamageCausedKnockbackForce = new Vector3(10, 10, 10) |
The force to apply to the object that gets damaged - this force will be rotated based on your knockback direction mode. So for example in 3D if you want to be pushed back the opposite direction, focus on the z component, with a force of 0,0,20 for example. More... | |
float | InvincibilityDuration = 0.5f |
The duration of the invincibility frames after the hit (in seconds) More... | |
bool | RepeatDamageOverTime = false |
Whether or not this damage on touch zone should apply damage over time. More... | |
int | AmountOfRepeats = 3 |
if in damage over time mode, how many times should damage be repeated? More... | |
float | DurationBetweenRepeats = 1f |
if in damage over time mode, the duration, in seconds, between two damages More... | |
bool | DamageOverTimeInterruptible = true |
if in damage over time mode, whether or not it can be interrupted (by calling the Health:InterruptDamageOverTime method More... | |
DamageType | RepeatedDamageType |
if in damage over time mode, the type of the repeated damage More... | |
Health | DamageTakenHealth |
The Health component on which to apply damage taken. If left empty, will attempty to grab one on this object. More... | |
float | DamageTakenEveryTime = 0 |
The amount of damage taken every time, whether what we collide with is damageable or not. More... | |
float | DamageTakenDamageable = 0 |
The amount of damage taken when colliding with a damageable object. More... | |
float | DamageTakenNonDamageable = 0 |
The amount of damage taken when colliding with something that is not damageable. More... | |
KnockbackStyles | DamageTakenKnockbackType = KnockbackStyles.NoKnockback |
the type of knockback to apply when taking damage More... | |
Vector3 | DamageTakenKnockbackForce = Vector3.zero |
The force to apply to the object that gets damaged. More... | |
float | DamageTakenInvincibilityDuration = 0.5f |
The duration of the invincibility frames after the hit (in seconds) More... | |
MMFeedbacks | HitDamageableFeedback |
the feedback to play when hitting a Damageable More... | |
MMFeedbacks | HitNonDamageableFeedback |
the feedback to play when hitting a non Damageable More... | |
MMFeedbacks | HitAnythingFeedback |
the feedback to play when hitting anything More... | |
UnityEvent< Health > | HitDamageableEvent |
an event to trigger when hitting a Damageable More... | |
UnityEvent< GameObject > | HitNonDamageableEvent |
an event to trigger when hitting a non Damageable More... | |
UnityEvent< GameObject > | HitAnythingEvent |
an event to trigger when hitting anything More... | |
Static Public Attributes | |
const TriggerAndCollisionMask | AllowedTriggerCallbacks |
Protected Member Functions | |
virtual void | Awake () |
On Awake we initialize our damage on touch area More... | |
virtual void | OnEnable () |
OnEnable we set the start time to the current timestamp More... | |
virtual void | GrabComponents () |
Stores components More... | |
virtual void | InitializeColliders () |
Initializes colliders, setting them as trigger if needed More... | |
virtual void | InitializeIgnoreList () |
Initializes the _ignoredGameObjects list if needed More... | |
virtual void | OnDisable () |
On disable we clear our ignore list More... | |
virtual void | OnValidate () |
On validate we ensure our inspector is in sync More... | |
virtual void | InitalizeGizmos () |
Initializes gizmo colors & settings More... | |
virtual void | OnDrawGizmos () |
draws a cube or sphere around the damage area More... | |
virtual void | Update () |
During last update, we store the position and velocity of the object More... | |
void | LateUpdate () |
On Late Update we store our position More... | |
virtual void | ComputeVelocity () |
Computes the velocity based on the object's last position More... | |
virtual void | DetermineDamageDirection () |
Determine the damage direction to pass to the Health Damage method More... | |
virtual void | Colliding (GameObject collider) |
When colliding, we apply the appropriate damage More... | |
virtual bool | EvaluateAvailability (GameObject collider) |
Checks whether or not damage should be applied this frame More... | |
virtual void | OnCollideWithDamageable (Health health) |
Describes what happens when colliding with a damageable object More... | |
virtual void | ApplyKnockback (float damage, List< TypedDamage > typedDamages) |
Applies knockback if needed More... | |
virtual bool | ShouldApplyKnockback (float damage, List< TypedDamage > typedDamages) |
Determines whether or not knockback should be applied More... | |
virtual void | ApplyKnockback2D () |
Applies knockback if we're in a 2D context More... | |
virtual void | ApplyKnockback3D () |
Applies knockback if we're in a 3D context More... | |
virtual void | OnCollideWithNonDamageable () |
Describes what happens when colliding with a non damageable object More... | |
virtual void | OnAnyCollision (GameObject other) |
Describes what could happens when colliding with anything More... | |
virtual void | SelfDamage (float damage) |
Applies damage to itself More... | |
Protected Attributes | |
Vector3 | _lastPosition |
Vector3 | _lastDamagePosition |
Vector3 | _velocity |
Vector3 | _knockbackForce |
Vector3 | _damageDirection |
float | _startTime = 0f |
Health | _colliderHealth |
TopDownController | _topDownController |
TopDownController | _colliderTopDownController |
List< GameObject > | _ignoredGameObjects |
Vector3 | _knockbackForceApplied |
CircleCollider2D | _circleCollider2D |
BoxCollider2D | _boxCollider2D |
SphereCollider | _sphereCollider |
BoxCollider | _boxCollider |
Color | _gizmosColor |
Vector3 | _gizmoSize |
Vector3 | _gizmoOffset |
Transform | _gizmoTransform |
bool | _twoD = false |
bool | _initializedFeedbacks = false |
Vector3 | _positionLastFrame |
Vector3 | _knockbackScriptDirection |
Vector3 | _relativePosition |
Vector3 | _damageScriptDirection |
Health | _collidingHealth |
Add this component to an object and it will cause damage to objects that collide with it.
|
protectedvirtual |
Applies knockback if needed
|
protectedvirtual |
Applies knockback if we're in a 2D context
|
protectedvirtual |
Applies knockback if we're in a 3D context
|
protectedvirtual |
On Awake we initialize our damage on touch area
|
virtual |
Clears the ignore list.
|
protectedvirtual |
When colliding, we apply the appropriate damage
collider |
|
protectedvirtual |
Computes the velocity based on the object's last position
|
protectedvirtual |
Determine the damage direction to pass to the Health Damage method
|
protectedvirtual |
Checks whether or not damage should be applied this frame
collider |
|
protectedvirtual |
Stores components
|
virtual |
Adds the gameobject set in parameters to the ignore list
newIgnoredGameObject | New ignored game object. |
|
protectedvirtual |
Initializes gizmo colors & settings
|
virtual |
Initializes ignore list, feedbacks, colliders and grabs components
|
protectedvirtual |
Initializes colliders, setting them as trigger if needed
|
virtual |
Initializes feedbacks
|
protectedvirtual |
Initializes the _ignoredGameObjects list if needed
|
protected |
On Late Update we store our position
|
protectedvirtual |
Describes what could happens when colliding with anything
|
protectedvirtual |
Describes what happens when colliding with a damageable object
health | Health. |
|
protectedvirtual |
Describes what happens when colliding with a non damageable object
|
protectedvirtual |
On disable we clear our ignore list
|
protectedvirtual |
draws a cube or sphere around the damage area
|
protectedvirtual |
OnEnable we set the start time to the current timestamp
|
virtual |
On trigger enter, we call our colliding endpoint
collider |
|
virtual |
On trigger enter 2D, we call our colliding endpoint
collider |
S
|
virtual |
On trigger stay, we call our colliding endpoint
collider |
|
virtual |
When a collision with the player is triggered, we give damage to the player and knock it back
collider | what's colliding with the object. |
|
protectedvirtual |
On validate we ensure our inspector is in sync
|
protectedvirtual |
Applies damage to itself
damage | Damage. |
|
virtual |
When damage direction is in script mode, lets you specify the direction of damage
newDirection |
|
virtual |
A public method letting you specify a gizmo offset
newOffset |
|
virtual |
A public method letting you (re)define gizmo size
newGizmoSize |
|
virtual |
When knockback is in script direction mode, lets you specify the direction of the knockback
newDirection |
|
protectedvirtual |
Determines whether or not knockback should be applied
|
virtual |
Removes the object set in parameters from the ignore list
ignoredGameObject | Ignored game object. |
|
protectedvirtual |
During last update, we store the position and velocity of the object
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
int MoreMountains.TopDownEngine.DamageOnTouch.AmountOfRepeats = 3 |
if in damage over time mode, how many times should damage be repeated?
KnockbackDirections MoreMountains.TopDownEngine.DamageOnTouch.DamageCausedKnockbackDirection = KnockbackDirections.BasedOnOwnerPosition |
The direction to apply the knockback.
Vector3 MoreMountains.TopDownEngine.DamageOnTouch.DamageCausedKnockbackForce = new Vector3(10, 10, 10) |
The force to apply to the object that gets damaged - this force will be rotated based on your knockback direction mode. So for example in 3D if you want to be pushed back the opposite direction, focus on the z component, with a force of 0,0,20 for example.
KnockbackStyles MoreMountains.TopDownEngine.DamageOnTouch.DamageCausedKnockbackType = KnockbackStyles.AddForce |
the type of knockback to apply when causing damage
DamageDirections MoreMountains.TopDownEngine.DamageOnTouch.DamageDirectionMode = DamageDirections.BasedOnVelocity |
how to determine the damage direction passed to the Health damage method, usually you'll use velocity for moving damage areas (projectiles) and owner position for melee weapons
bool MoreMountains.TopDownEngine.DamageOnTouch.DamageOverTimeInterruptible = true |
if in damage over time mode, whether or not it can be interrupted (by calling the Health:InterruptDamageOverTime method
float MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenDamageable = 0 |
The amount of damage taken when colliding with a damageable object.
float MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenEveryTime = 0 |
The amount of damage taken every time, whether what we collide with is damageable or not.
Health MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenHealth |
The Health component on which to apply damage taken. If left empty, will attempty to grab one on this object.
float MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenInvincibilityDuration = 0.5f |
The duration of the invincibility frames after the hit (in seconds)
Vector3 MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenKnockbackForce = Vector3.zero |
The force to apply to the object that gets damaged.
KnockbackStyles MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenKnockbackType = KnockbackStyles.NoKnockback |
the type of knockback to apply when taking damage
float MoreMountains.TopDownEngine.DamageOnTouch.DamageTakenNonDamageable = 0 |
The amount of damage taken when colliding with something that is not damageable.
float MoreMountains.TopDownEngine.DamageOnTouch.DurationBetweenRepeats = 1f |
if in damage over time mode, the duration, in seconds, between two damages
UnityEvent<GameObject> MoreMountains.TopDownEngine.DamageOnTouch.HitAnythingEvent |
an event to trigger when hitting anything
MMFeedbacks MoreMountains.TopDownEngine.DamageOnTouch.HitAnythingFeedback |
the feedback to play when hitting anything
UnityEvent<Health> MoreMountains.TopDownEngine.DamageOnTouch.HitDamageableEvent |
an event to trigger when hitting a Damageable
MMFeedbacks MoreMountains.TopDownEngine.DamageOnTouch.HitDamageableFeedback |
the feedback to play when hitting a Damageable
UnityEvent<GameObject> MoreMountains.TopDownEngine.DamageOnTouch.HitNonDamageableEvent |
an event to trigger when hitting a non Damageable
MMFeedbacks MoreMountains.TopDownEngine.DamageOnTouch.HitNonDamageableFeedback |
the feedback to play when hitting a non Damageable
float MoreMountains.TopDownEngine.DamageOnTouch.InvincibilityDuration = 0.5f |
The duration of the invincibility frames after the hit (in seconds)
float MoreMountains.TopDownEngine.DamageOnTouch.MaxDamageCaused = 10f |
The max amount of health to remove from the player's health.
float MoreMountains.TopDownEngine.DamageOnTouch.MinDamageCaused = 10f |
The min amount of health to remove from the player's health.
GameObject MoreMountains.TopDownEngine.DamageOnTouch.Owner |
the owner of the DamageOnTouch zone
bool MoreMountains.TopDownEngine.DamageOnTouch.RepeatDamageOverTime = false |
Whether or not this damage on touch zone should apply damage over time.
DamageType MoreMountains.TopDownEngine.DamageOnTouch.RepeatedDamageType |
if in damage over time mode, the type of the repeated damage
LayerMask MoreMountains.TopDownEngine.DamageOnTouch.TargetLayerMask |
the layers that will be damaged by this object
TriggerAndCollisionMask MoreMountains.TopDownEngine.DamageOnTouch.TriggerFilter = AllowedTriggerCallbacks |
Defines on what triggers the damage should be applied, by default on enter and stay (both 2D and 3D) but this field will let you exclude triggers if needed.
List<TypedDamage> MoreMountains.TopDownEngine.DamageOnTouch.TypedDamages |
a list of typed damage definitions that will be applied on top of the base damage