Function KinematicBody.moveAndSlide
Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a KinematicBody
or RigidBody
, it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes.
linear_velocity
is the velocity vector (typically meters per second). Unlike in moveAndCollide
, you should not multiply it by delta
— the physics engine handles applying the velocity.
up_direction
is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of Vector3(0, 0, 0)
, everything is considered a wall.
If stop_on_slope
is true
, body will not slide on slopes if you include gravity in linear_velocity
.
If the body collides, it will change direction a maximum of max_slides
times before it stops.
floor_max_angle
is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees.
If infinite_inertia
is true
, body will be able to push RigidBody
nodes, but it won't also detect any collisions with them. If false
, it will interact with RigidBody
nodes like with StaticBody
.
Returns the linear_velocity
vector, rotated and/or scaled if a slide collision occurred. To get detailed information about collisions that occurred, use getSlideCollision
.
Vector3 moveAndSlide
(
const(Vector3) linear_velocity,
const(Vector3) up_direction = Vector3(0.00000F, 0.00000F, 0.00000F, ) .this(0.00000F, 0.00000F, 0.00000F),
const(bool) stop_on_slope = false,
const(long) max_slides = 4L,
const(double) floor_max_angle = 0.785398,
const(bool) infinite_inertia = true
) nothrow @nogc;