Knockback

Parameters

fromPosition: Vector3

The position from which knockback should be applied. If this is equal to the position of the hit entity, no knockback will be applied.

horizontal: number | nil

The amount of horizontal knockback applied. Defaults to 1. A value of 0 will apply no horizontal knockback.

vertical: number | nil

The amount of vertical knockback applied. Defaults to 1. A value of 0 will apply no vertical knockback.

Example usage:

-- All damage events launch the hit entity into the air with no damage
Events.EntityDamage(function(event)
    event.damage = 0
    event.knockback.horizontal = 0.5
    event.knockback.vertical = 5
    event.knockback.fromPosition = event.entity:getPosition() - Vector3.new(0,3,0)
end)
-- Cancels knockback for all damage events
Events.EntityDamage(function(event)
    event.knockback.horizontal = 0
    event.knockback.vertical = 0
end)

Last updated