Table of Contents

Class KnockbackHitAction

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Action that applies a knockback force to a target character, pushing them away from the source.

[Serializable]
public class KnockbackHitAction : BaseAction, IAction
Inheritance
KnockbackHitAction
Implements
Inherited Members

Remarks

Direction follows the attack (Direction, ResolveOrigin(KnockbackDirection, bool, bool, bool, AbilitySpawnTarget)). An area of effect is a blast radius and pushes everyone it catches away from its centre; a projectile pushes along its own flight, so a victim facing the shot is driven backwards; a melee swing pushes away from the one swinging. It used to push along the ability object's forward in every case, which sent everyone in a blast the same way, and did nothing at all for an ability with no object (a self-centred area), because there was no forward to read.

Who moves. A player is moved through its KCC motor (a velocity impulse the motor resolves against collision, prediction and reconciliation). An NPC — monsters and wildlife alike — is moved through its server brain (ApplyKnockback(Vector3)), which slides the NavMesh agent, so it can be shoved along the ground but never through a wall or off the mesh. Both are horizontal for an NPC; a player keeps the full direction.

The displacement is SERVER ONLY — see the note in Execute(ICharacter, EventData) for why this is the one feedback action that did not move to EcaAuthority.MayPredict. The victim's own client receives it through the reconcile (or the NPC's transform stream), and the attacker's client plays a cosmetic flinch (PlayPredictedReaction(ICharacter, EventData, float)) in the meantime.

Fields

DefaultDeceleration

How fast a knockback bleeds off, metres per second per second: the NPC brain's law (AIController.KnockbackDeceleration) and the attacker's predicted shove (Shove(Vector3, float, float)), so the shove drawn now is the slide the server makes.

public const float DefaultDeceleration = 24

Field Value

float

Direction

Which way the victim is pushed. Auto decides from the attack's shape.

[Tooltip("Which way the victim is pushed. Auto: area = away from the blast centre, projectile = along its flight, melee = away from the caster.")]
public KnockbackDirection Direction

Field Value

KnockbackDirection

ForceValue

The value provider that determines the initial knockback force applied to the target.

[Tooltip("The value provider that determines the initial knockback force (metres per second of push).")]
[SerializeReference]
public IFloatValueProvider ForceValue

Field Value

IFloatValueProvider

Methods

Execute(ICharacter, EventData)

Applies a knockback effect to the target character if they are not immortal.

public override void Execute(ICharacter initiator, EventData eventData)

Parameters

initiator ICharacter

The character initiating the action.

eventData EventData

The event data containing the target and ability information.