KinematicBody2D.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 KinematicBody2D or RigidBody2D, 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 a value in pixels per second. Unlike in for example moveAndCollide, you should not multiply it with delta — this is done by the method. floor_normal 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 Vector2(0, 0), everything is considered a wall. This is useful for topdown games. TODO: Update for stop_on_slope argument. If the body is standing on a slope and the horizontal speed (relative to the floor's speed) goes below slope_stop_min_velocity, the body will stop completely. This prevents the body from sliding down slopes when you include gravity in linear_velocity. When set to lower values, the body will not be able to stand still on steep slopes. If the body collides, it will change direction a maximum of max_bounces 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. Returns the movement that remained when the body stopped. To get more detailed information about collisions that occurred, use getSlideCollision.

struct KinematicBody2D
@nogc nothrow
Vector2
moveAndSlide
(
in Vector2 linear_velocity
,
in Vector2 floor_normal = Vector2(0, 0)
,
in bool infinite_inertia = true
,
in bool stop_on_slope = false
,
in long max_bounces = 4
,
in double floor_max_angle = 0.785398
)

Meta