Character Body

self:get_slide_collision

Shared

Retrieves the details of a collision recorded during the last slide movement

Syntax

local collision = self:get_slide_collision(
    index
)

Parameters

TypeNameDescription
intindexZero-based index of the collision, up to self:get_slide_collision_count() - 1

Returns

TypeNameDescription
table | boolcollisionCollision data, false if the index is out of range
Refer Collision section

Collision

TypeNameDescription
intcollider_net_idNetwork id of the collider, 0 if it is not replicated
vector3normalCollision normal as {x, y, z}
vector3travelDistance travelled before the collision as {x, y, z}
vector3remainderRemaining motion after the collision as {x, y, z}
vector3positionWorld-space collision point as {x, y, z}
vector3collider_velocityVelocity of the collider as {x, y, z}

Examples

Print every slide collision normal
local entity = physics.character.create()

for index = 0, entity:get_slide_collision_count() - 1 do
    local collision = entity:get_slide_collision(index)

    if collision then
        core.engine.print("info", "Normal:", util.table.unpack(collision.normal))
    end
end

On this page