Skip to content

CharacterBody2D

Eduard Gushchin edited this page Jun 21, 2026 · 5 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.CharacterBody2D
Namespace Electron2D
Kind class
Category Physics

Overview

Provides a 2D character body moved directly by user code.

Syntax

public class Electron2D.CharacterBody2D : Electron2D.PhysicsBody2D

Remarks

Electron2D.CharacterBody2D is not moved by forces in the 0.1.0 Preview baseline. Assign Electron2D.CharacterBody2D.Velocity in Electron2D.Node._PhysicsProcess(System.Double) and call Electron2D.CharacterBody2D.MoveAndSlide to move with managed AABB collision response.

Thread Safety

This type is not synchronized. Create and mutate nodes on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.KinematicCollision2D
  • Electron2D.PhysicsBody2D

Members

Member Kind Summary
FloorBlockOnWall Property Gets or sets whether floor movement should avoid walking on walls.
FloorConstantSpeed Property Gets or sets whether floor movement should preserve constant speed on slopes.
FloorMaxAngle Property Gets or sets the maximum angle in radians that still counts as floor or ceiling.
FloorSnapLength Property Gets or sets the floor snapping distance used by Electron2D.CharacterBody2D.MoveAndSlide.
FloorStopOnSlope Property Gets or sets whether a standing body should stop on slopes.
MaxSlides Property Gets or sets the maximum number of slide iterations for Electron2D.CharacterBody2D.MoveAndSlide.
MotionMode Property Gets or sets the motion mode used by Electron2D.CharacterBody2D.MoveAndSlide.
PlatformFloorLayers Property Gets or sets the layers treated as moving floor platforms.
PlatformOnLeave Property Gets or sets how platform velocity should be handled when leaving a platform.
PlatformWallLayers Property Gets or sets the layers treated as moving wall platforms.
SafeMargin Property Gets or sets the safe margin used by Electron2D.CharacterBody2D.MoveAndSlide.
SlideOnCeiling Property Gets or sets whether the body should slide along ceilings.
UpDirection Property Gets or sets the up direction used to classify floor, wall and ceiling collisions.
Velocity Property Gets or sets the velocity used by Electron2D.CharacterBody2D.MoveAndSlide.
WallMinSlideAngle Property Gets or sets the minimum slide angle for walls.
Electron2D.CharacterBody2D() Constructor Initializes a new instance of the Electron2D.CharacterBody2D class.
ApplyFloorSnap() Method Applies floor snapping immediately using Electron2D.CharacterBody2D.FloorSnapLength.
GetFloorAngle(Electron2D.Vector2?) Method Gets the angle of the last floor collision.
GetFloorNormal() Method Gets the normal of the last floor collision.
GetLastMotion() Method Gets the last motion applied by Electron2D.CharacterBody2D.MoveAndSlide.
GetLastSlideCollision() Method Gets the last slide collision.
GetPlatformVelocity() Method Gets the velocity of the platform currently treated as floor or wall.
GetPositionDelta() Method Gets the position delta applied by the last Electron2D.CharacterBody2D.MoveAndSlide call.
GetRealVelocity() Method Gets the effective velocity from the last applied position delta.
GetSlideCollision(System.Int32) Method Gets a slide collision by index.
GetSlideCollisionCount() Method Gets the number of slide collisions from the last Electron2D.CharacterBody2D.MoveAndSlide call.
GetWallNormal() Method Gets the normal of the last wall collision.
IsOnCeiling() Method Checks whether the last slide movement touched a ceiling.
IsOnCeilingOnly() Method Checks whether the last slide movement touched only a ceiling.
IsOnFloor() Method Checks whether the last slide movement touched a floor.
IsOnFloorOnly() Method Checks whether the last slide movement touched only a floor.
IsOnWall() Method Checks whether the last slide movement touched a wall.
IsOnWallOnly() Method Checks whether the last slide movement touched only a wall.
MoveAndSlide() Method Moves the body using Electron2D.CharacterBody2D.Velocity and slides along collisions.

Member Details

FloorBlockOnWall

Kind: Property

public System.Boolean FloorBlockOnWall { get; set; }

Summary

Gets or sets whether floor movement should avoid walking on walls.

Remarks

The 0.1.0 Preview baseline stores this setting for API completeness. Wall classification still uses Electron2D.CharacterBody2D.FloorMaxAngle and Electron2D.CharacterBody2D.UpDirection.

Value

true when wall blocking is requested for floor movement; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnWall

FloorConstantSpeed

Kind: Property

public System.Boolean FloorConstantSpeed { get; set; }

Summary

Gets or sets whether floor movement should preserve constant speed on slopes.

Remarks

The 0.1.0 Preview baseline stores this setting for API completeness. The simple AABB solver does not yet implement full constant-speed slope movement.

Value

true when constant floor speed behavior is requested; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.FloorStopOnSlope

FloorMaxAngle

Kind: Property

public System.Single FloorMaxAngle { get; set; }

Summary

Gets or sets the maximum angle in radians that still counts as floor or ceiling.

Remarks

Collision normals whose angle from Electron2D.CharacterBody2D.UpDirection is less than or equal to this value are treated as floor. The opposite direction is treated as ceiling.

Value

The non-negative angle in radians.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetFloorAngle(System.Nullable{Electron2D.Vector2})
  • Electron2D.CharacterBody2D.UpDirection

FloorSnapLength

Kind: Property

public System.Single FloorSnapLength { get; set; }

Summary

Gets or sets the floor snapping distance used by Electron2D.CharacterBody2D.MoveAndSlide.

Remarks

When the body is not moving upward and no floor collision happened during the main slide pass, Electron2D.CharacterBody2D.MoveAndSlide attempts a snap movement opposite Electron2D.CharacterBody2D.UpDirection.

Value

The non-negative snap distance in world units.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.ApplyFloorSnap
  • Electron2D.CharacterBody2D.IsOnFloor

FloorStopOnSlope

Kind: Property

public System.Boolean FloorStopOnSlope { get; set; }

Summary

Gets or sets whether a standing body should stop on slopes.

Remarks

The 0.1.0 Preview baseline stores this setting for API completeness. The simple AABB solver does not yet implement full slope stop behavior.

Value

true when slope stop behavior is requested; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.FloorConstantSpeed

MaxSlides

Kind: Property

public System.Int32 MaxSlides { get; set; }

Summary

Gets or sets the maximum number of slide iterations for Electron2D.CharacterBody2D.MoveAndSlide.

Remarks

Each iteration consumes the remaining motion after a collision by sliding it along the collision normal.

Value

A positive number of slide iterations.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is less than or equal to zero.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.MoveAndSlide

MotionMode

Kind: Property

public Electron2D.CharacterBody2D.MotionModeEnum MotionMode { get; set; }

Summary

Gets or sets the motion mode used by Electron2D.CharacterBody2D.MoveAndSlide.

Remarks

Electron2D.CharacterBody2D.MotionModeEnum.Grounded classifies collisions into floor, wall and ceiling. Electron2D.CharacterBody2D.MotionModeEnum.Floating treats slide collisions as walls.

Value

The current Electron2D.CharacterBody2D.MotionModeEnum.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnFloor
  • Electron2D.CharacterBody2D.IsOnWall

PlatformFloorLayers

Kind: Property

public System.UInt32 PlatformFloorLayers { get; set; }

Summary

Gets or sets the layers treated as moving floor platforms.

Remarks

When a floor collision occurs with a Electron2D.StaticBody2D whose collision layer is included in this mask, Electron2D.CharacterBody2D.GetPlatformVelocity returns that body's Electron2D.StaticBody2D.ConstantLinearVelocity.

Value

A bit mask matched against Electron2D.CollisionObject2D.CollisionLayer.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetPlatformVelocity
  • Electron2D.CharacterBody2D.PlatformWallLayers

PlatformOnLeave

Kind: Property

public Electron2D.CharacterBody2D.PlatformOnLeaveEnum PlatformOnLeave { get; set; }

Summary

Gets or sets how platform velocity should be handled when leaving a platform.

Remarks

The 0.1.0 Preview baseline stores this setting for API completeness. Complex platform leave velocity application is reserved for a later solver pass.

Value

The selected Electron2D.CharacterBody2D.PlatformOnLeaveEnum policy.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetPlatformVelocity

PlatformWallLayers

Kind: Property

public System.UInt32 PlatformWallLayers { get; set; }

Summary

Gets or sets the layers treated as moving wall platforms.

Remarks

When a wall collision occurs and the collider layer is included in this mask, Electron2D.CharacterBody2D.GetPlatformVelocity returns the collider velocity.

Value

A bit mask matched against Electron2D.CollisionObject2D.CollisionLayer.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetPlatformVelocity
  • Electron2D.CharacterBody2D.PlatformFloorLayers

SafeMargin

Kind: Property

public System.Single SafeMargin { get; set; }

Summary

Gets or sets the safe margin used by Electron2D.CharacterBody2D.MoveAndSlide.

Remarks

The managed AABB solver expands target bounds by this margin before sweeping the body.

Value

The non-negative collision margin in world units.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.PhysicsBody2D.MoveAndCollide(Electron2D.Vector2,System.Boolean,System.Single,System.Boolean)

SlideOnCeiling

Kind: Property

public System.Boolean SlideOnCeiling { get; set; }

Summary

Gets or sets whether the body should slide along ceilings.

Remarks

When this property is false, a ceiling collision clears the vertical component of Electron2D.CharacterBody2D.Velocity in the current baseline.

Value

true to allow ceiling slide response; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnCeiling

UpDirection

Kind: Property

public Electron2D.Vector2 UpDirection { get; set; }

Summary

Gets or sets the up direction used to classify floor, wall and ceiling collisions.

Remarks

Floor, wall and ceiling classification compares collision normals against this direction and Electron2D.CharacterBody2D.FloorMaxAngle.

Value

A finite non-zero vector. The setter stores the normalized direction.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is zero or contains non-finite components.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.FloorMaxAngle
  • Electron2D.CharacterBody2D.GetFloorAngle(System.Nullable{Electron2D.Vector2})

Velocity

Kind: Property

public Electron2D.Vector2 Velocity { get; set; }

Summary

Gets or sets the velocity used by Electron2D.CharacterBody2D.MoveAndSlide.

Remarks

Electron2D.CharacterBody2D.MoveAndSlide consumes this value using the fixed physics tick of 1/60 seconds and updates it after slide collisions.

Value

The velocity in units per second.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetRealVelocity
  • Electron2D.CharacterBody2D.MoveAndSlide

WallMinSlideAngle

Kind: Property

public System.Single WallMinSlideAngle { get; set; }

Summary

Gets or sets the minimum slide angle for walls.

Remarks

The 0.1.0 Preview baseline stores this setting for API completeness. The simple AABB solver does not yet implement wall minimum slide angle filtering.

Value

The non-negative angle in radians.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnWall

Electron2D.CharacterBody2D()

Kind: Constructor

public Electron2D.CharacterBody2D()

Summary

Initializes a new instance of the Electron2D.CharacterBody2D class.

Remarks

New instances start with zero velocity, upward floor classification and the managed axis-aligned bounding-box movement baseline.

Thread Safety

This constructor is not synchronized. Create nodes on the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D

ApplyFloorSnap()

Kind: Method

public System.Void ApplyFloorSnap()()

Summary

Applies floor snapping immediately using Electron2D.CharacterBody2D.FloorSnapLength.

Remarks

This method moves the body opposite Electron2D.CharacterBody2D.UpDirection by Electron2D.CharacterBody2D.FloorSnapLength when a floor collision is found. It is useful when code changes velocity or position before the next Electron2D.CharacterBody2D.MoveAndSlide call.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.FloorSnapLength
  • Electron2D.CharacterBody2D.MoveAndSlide

GetFloorAngle(Electron2D.Vector2?)

Kind: Method

public System.Single GetFloorAngle(Electron2D.Vector2?)(Electron2D.Vector2? upDirection)

Summary

Gets the angle of the last floor collision.

Remarks

When upDirection is null, the current Electron2D.CharacterBody2D.UpDirection is used. If the body is not on a floor after the last Electron2D.CharacterBody2D.MoveAndSlide call, the method returns 0.

Parameters

  • upDirection: Optional up direction used as reference.

Returns

The floor angle in radians, or 0 when no floor collision exists.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetFloorNormal
  • Electron2D.CharacterBody2D.IsOnFloor

GetFloorNormal()

Kind: Method

public Electron2D.Vector2 GetFloorNormal()()

Summary

Gets the normal of the last floor collision.

Remarks

This value is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call.

Returns

The floor normal, or Electron2D.Vector2.Zero when not on floor.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetFloorAngle(System.Nullable{Electron2D.Vector2})
  • Electron2D.CharacterBody2D.IsOnFloor

GetLastMotion()

Kind: Method

public Electron2D.Vector2 GetLastMotion()()

Summary

Gets the last motion applied by Electron2D.CharacterBody2D.MoveAndSlide.

Remarks

The value is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call and accumulates the travel applied by slide and snap movement.

Returns

The last slide motion.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetPositionDelta

GetLastSlideCollision()

Kind: Method

public Electron2D.KinematicCollision2D GetLastSlideCollision()()

Summary

Gets the last slide collision.

Remarks

The returned collision object belongs to the data collected during the most recent Electron2D.CharacterBody2D.MoveAndSlide call.

Returns

The last slide collision, or null when there are no slide collisions.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetSlideCollision(System.Int32)
  • Electron2D.CharacterBody2D.GetSlideCollisionCount

GetPlatformVelocity()

Kind: Method

public Electron2D.Vector2 GetPlatformVelocity()()

Summary

Gets the velocity of the platform currently treated as floor or wall.

Remarks

The baseline reads Electron2D.StaticBody2D.ConstantLinearVelocity from floor or wall colliders whose layer is included in the relevant platform mask.

Returns

The platform velocity, or Electron2D.Vector2.Zero when none is tracked.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.PlatformFloorLayers
  • Electron2D.CharacterBody2D.PlatformWallLayers

GetPositionDelta()

Kind: Method

public Electron2D.Vector2 GetPositionDelta()()

Summary

Gets the position delta applied by the last Electron2D.CharacterBody2D.MoveAndSlide call.

Remarks

The value is the difference between Electron2D.Node2D.Position before and after the last slide call.

Returns

The last position delta.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetLastMotion
  • Electron2D.CharacterBody2D.GetRealVelocity

GetRealVelocity()

Kind: Method

public Electron2D.Vector2 GetRealVelocity()()

Summary

Gets the effective velocity from the last applied position delta.

Remarks

The value is Electron2D.CharacterBody2D.GetPositionDelta divided by the fixed physics tick used by the 0.1.0 Preview baseline.

Returns

The last real velocity.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetPositionDelta
  • Electron2D.CharacterBody2D.Velocity

GetSlideCollision(System.Int32)

Kind: Method

public Electron2D.KinematicCollision2D GetSlideCollision(System.Int32)(System.Int32 slideIdx)

Summary

Gets a slide collision by index.

Remarks

Valid indices are in the range 0 through GetSlideCollisionCount() - 1. Out-of-range indices return null instead of throwing.

Parameters

  • slideIdx: The zero-based slide collision index.

Returns

The slide collision, or null when the index is outside the current range.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetLastSlideCollision
  • Electron2D.CharacterBody2D.GetSlideCollisionCount

GetSlideCollisionCount()

Kind: Method

public System.Int32 GetSlideCollisionCount()()

Summary

Gets the number of slide collisions from the last Electron2D.CharacterBody2D.MoveAndSlide call.

Remarks

The count is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call.

Returns

The slide collision count.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetSlideCollision(System.Int32)

GetWallNormal()

Kind: Method

public Electron2D.Vector2 GetWallNormal()()

Summary

Gets the normal of the last wall collision.

Remarks

This value is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call.

Returns

The wall normal, or Electron2D.Vector2.Zero when not on wall.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnWall

IsOnCeiling()

Kind: Method

public System.Boolean IsOnCeiling()()

Summary

Checks whether the last slide movement touched a ceiling.

Remarks

The value describes the most recent Electron2D.CharacterBody2D.MoveAndSlide call and is reset before the next slide pass.

Returns

true when on ceiling; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnCeilingOnly
  • Electron2D.CharacterBody2D.SlideOnCeiling

IsOnCeilingOnly()

Kind: Method

public System.Boolean IsOnCeilingOnly()()

Summary

Checks whether the last slide movement touched only a ceiling.

Remarks

This method returns false if the last slide movement also touched a floor or wall.

Returns

true when only ceiling state is active; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnCeiling

IsOnFloor()

Kind: Method

public System.Boolean IsOnFloor()()

Summary

Checks whether the last slide movement touched a floor.

Remarks

Floor state is classified with Electron2D.CharacterBody2D.UpDirection and Electron2D.CharacterBody2D.FloorMaxAngle when Electron2D.CharacterBody2D.MotionMode is Electron2D.CharacterBody2D.MotionModeEnum.Grounded.

Returns

true when on floor; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetFloorNormal
  • Electron2D.CharacterBody2D.IsOnFloorOnly

IsOnFloorOnly()

Kind: Method

public System.Boolean IsOnFloorOnly()()

Summary

Checks whether the last slide movement touched only a floor.

Remarks

This method returns false if the last slide movement also touched a wall or ceiling.

Returns

true when only floor state is active; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnFloor

IsOnWall()

Kind: Method

public System.Boolean IsOnWall()()

Summary

Checks whether the last slide movement touched a wall.

Remarks

Wall state is set for slide collisions that are neither floor nor ceiling in grounded mode, and for all slide collisions in floating mode.

Returns

true when on wall; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetWallNormal
  • Electron2D.CharacterBody2D.IsOnWallOnly

IsOnWallOnly()

Kind: Method

public System.Boolean IsOnWallOnly()()

Summary

Checks whether the last slide movement touched only a wall.

Remarks

This method returns false if the last slide movement also touched a floor or ceiling.

Returns

true when only wall state is active; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.IsOnWall

MoveAndSlide()

Kind: Method

public System.Boolean MoveAndSlide()()

Summary

Moves the body using Electron2D.CharacterBody2D.Velocity and slides along collisions.

Remarks

The method consumes Electron2D.CharacterBody2D.Velocity over the fixed physics tick, applies at most Electron2D.CharacterBody2D.MaxSlides slide iterations, updates floor/wall/ceiling state and stores collision data for Electron2D.CharacterBody2D.GetSlideCollision(System.Int32).

The 0.1.0 Preview baseline uses managed AABB sweeps against Electron2D.StaticBody2D nodes. It is a gameplay baseline, not a final narrow-phase solver.

Returns

true when at least one collision happened; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.GetSlideCollision(System.Int32)
  • Electron2D.CharacterBody2D.Velocity
  • Electron2D.PhysicsBody2D.MoveAndCollide(Electron2D.Vector2,System.Boolean,System.Single,System.Boolean)

Clone this wiki locally