Click or drag to resize

KinematicBodyMoveAndSlide Method

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 and rotating platforms, or to make nodes push other nodes.

This method should be used in _PhysicsProcess(Single) (or in a method called by _PhysicsProcess(Single)), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.

linear_velocity is the velocity vector (typically meters per second). Unlike in MoveAndCollide(Vector3, Boolean, Boolean, Boolean), 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 when you include gravity in linear_velocity and the body is standing still.

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(Int32).

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public Vector3 MoveAndSlide(
	Vector3 linearVelocity,
	Vector3? upDirection = null,
	bool stopOnSlope = false,
	int maxSlides = 4,
	float floorMaxAngle = 0.785398f,
	bool infiniteInertia = true
)

Parameters

linearVelocity
Type: GodotVector3

[Missing <param name="linearVelocity"/> documentation for "M:Godot.KinematicBody.MoveAndSlide(Godot.Vector3,System.Nullable{Godot.Vector3},System.Boolean,System.Int32,System.Single,System.Boolean)"]

upDirection (Optional)
Type: SystemNullableVector3
If the parameter is null, then the default value is new Vector3(0, 0, 0)
stopOnSlope (Optional)
Type: SystemBoolean

[Missing <param name="stopOnSlope"/> documentation for "M:Godot.KinematicBody.MoveAndSlide(Godot.Vector3,System.Nullable{Godot.Vector3},System.Boolean,System.Int32,System.Single,System.Boolean)"]

maxSlides (Optional)
Type: SystemInt32

[Missing <param name="maxSlides"/> documentation for "M:Godot.KinematicBody.MoveAndSlide(Godot.Vector3,System.Nullable{Godot.Vector3},System.Boolean,System.Int32,System.Single,System.Boolean)"]

floorMaxAngle (Optional)
Type: SystemSingle

[Missing <param name="floorMaxAngle"/> documentation for "M:Godot.KinematicBody.MoveAndSlide(Godot.Vector3,System.Nullable{Godot.Vector3},System.Boolean,System.Int32,System.Single,System.Boolean)"]

infiniteInertia (Optional)
Type: SystemBoolean

[Missing <param name="infiniteInertia"/> documentation for "M:Godot.KinematicBody.MoveAndSlide(Godot.Vector3,System.Nullable{Godot.Vector3},System.Boolean,System.Int32,System.Single,System.Boolean)"]

Return Value

Type: Vector3

[Missing <returns> documentation for "M:Godot.KinematicBody.MoveAndSlide(Godot.Vector3,System.Nullable{Godot.Vector3},System.Boolean,System.Int32,System.Single,System.Boolean)"]

See Also