self:move_and_slide

Client

Moves the character body using its current velocity, automatically sliding along floors, walls, and ceilings according to its motion mode


Syntax

local collided = self:move_and_slide()

Parameters

No parameters are accepted by this function

Returns

TypeNameDescription
boolcollidedtrue if the body collided with something during the move, false otherwise

Examples

Move a character body every frame
local entity = physics.character.create()

util.event.on("sandbox:draw", function()
    entity:set_velocity({0, -9.8, 0})
    entity:move_and_slide()
end)

On this page