Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
KnockbackFeedback Class Reference

Detailed Description

Put this script on an object to allow it to take knockback.

Documentation updated 10/10/2024

Author
Stephen Nuttall

Public Member Functions

void ApplyKnockback (GameObject sender)
 Applies knockback to this object by adding force in the opposite direction of the sender.
 
void ApplyKnockback (GameObject sender, float strength)
 Applies knockback to this object by adding force in the opposite direction of the sender. This overload allows one to specify the strength of the knockback.
 

Public Attributes

UnityEvent OnBegin
 Event that is triggered when the knockback begins to be applied. Functions can be subscribed to this events in the Unity Editor.
 
UnityEvent OnDone
 Event that is triggered when the knockback begins to be applied. Functions can be subscribed to this events in the Unity Editor.
 

Protected Attributes

float kbDelay = 0.15f
 How long after the knockback starts the force on the force should stop being applied.
 
float defaultStrength = 50
 The strength of the knockback (amount of force applied) if no strength is given.
 
float kbResistance = 0
 The amount of strength subtracted from any knockback applied to this object.
 

Private Member Functions

IEnumerator Reset ()
 Waits kbDelay seconds, then resets the object's velocity.
 

Private Attributes

Rigidbody2D rb
 Reference to the rigidbody component of the object.
 

Member Function Documentation

◆ ApplyKnockback() [1/2]

void KnockbackFeedback.ApplyKnockback ( GameObject sender)

Applies knockback to this object by adding force in the opposite direction of the sender.

Parameters
senderThe object causing the knockback to happen.

◆ ApplyKnockback() [2/2]

void KnockbackFeedback.ApplyKnockback ( GameObject sender,
float strength )

Applies knockback to this object by adding force in the opposite direction of the sender. This overload allows one to specify the strength of the knockback.

Parameters
senderThe object causing the knockback to happen.
strengthThe strength of the force applied to the object.

◆ Reset()

IEnumerator KnockbackFeedback.Reset ( )
private

Waits kbDelay seconds, then resets the object's velocity.

Member Data Documentation

◆ defaultStrength

float KnockbackFeedback.defaultStrength = 50
protected

The strength of the knockback (amount of force applied) if no strength is given.

◆ kbDelay

float KnockbackFeedback.kbDelay = 0.15f
protected

How long after the knockback starts the force on the force should stop being applied.

◆ kbResistance

float KnockbackFeedback.kbResistance = 0
protected

The amount of strength subtracted from any knockback applied to this object.

◆ OnBegin

UnityEvent KnockbackFeedback.OnBegin

Event that is triggered when the knockback begins to be applied. Functions can be subscribed to this events in the Unity Editor.

◆ OnDone

UnityEvent KnockbackFeedback.OnDone

Event that is triggered when the knockback begins to be applied. Functions can be subscribed to this events in the Unity Editor.

◆ rb

Rigidbody2D KnockbackFeedback.rb
private

Reference to the rigidbody component of the object.


The documentation for this class was generated from the following file: