KnockbackMotor

Manages directional knockback impulse, deceleration friction, and collision against solid walls.

Constructor

new KnockbackMotor(configopt)

Parameters:
NameTypeAttributesDescription
configObject<optional>
Properties
NameTypeAttributesDefaultDescription
decaynumber<optional>
8.0

Friction/decay rate per second

minVelocitynumber<optional>
0.01

Threshold to stop knockback

Classes

KnockbackMotor

Methods

applyImpulse(vx, vy)

Apply a directional knockback impulse.

Parameters:
NameTypeDescription
vxnumber
vynumber

step(deltaTime, currentBounds, solidObstacles) → {Object}

Step knockback displacement against solid obstacles. If knockback collides into a wall, movement stops at the wall surface and normal velocity is zeroed (preventing wall clipping).

Parameters:
NameTypeDescription
deltaTimenumber
currentBoundsObject

Entity bounds { left, right, top, bottom }

solidObstaclesArray.<Object>

List of static { left, right, top, bottom }

Returns:

{ dx: number, dy: number, hitWall: boolean }

Type: 
Object

stop()

Clear active knockback immediately.