-
Notifications
You must be signed in to change notification settings - Fork 0
CharacterBody2D
Home | API by Category | Complete API Index | API Compatibility
| Field | Value |
|---|---|
| Full name | Electron2D.CharacterBody2D |
| Namespace | Electron2D |
| Kind | class |
| Category | Physics |
Provides a 2D character body moved directly by user code.
public class Electron2D.CharacterBody2D : Electron2D.PhysicsBody2DElectron2D.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.
This type is not synchronized. Create and mutate nodes on the main scene thread.
This type is available since Electron2D 0.1.0 Preview.
Electron2D.KinematicCollision2DElectron2D.PhysicsBody2D
| 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. |
Kind: Property
public System.Boolean FloorBlockOnWall { get; set; }Gets or sets whether floor movement should avoid walking on walls.
The 0.1.0 Preview baseline stores this setting for API completeness. Wall
classification still uses Electron2D.CharacterBody2D.FloorMaxAngle and
Electron2D.CharacterBody2D.UpDirection.
true when wall blocking is requested for floor movement; otherwise, false.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnWall
Kind: Property
public System.Boolean FloorConstantSpeed { get; set; }Gets or sets whether floor movement should preserve constant speed on slopes.
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.
true when constant floor speed behavior is requested; otherwise, false.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.FloorStopOnSlope
Kind: Property
public System.Single FloorMaxAngle { get; set; }Gets or sets the maximum angle in radians that still counts as floor or ceiling.
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.
The non-negative angle in radians.
-
System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetFloorAngle(System.Nullable{Electron2D.Vector2})Electron2D.CharacterBody2D.UpDirection
Kind: Property
public System.Single FloorSnapLength { get; set; }Gets or sets the floor snapping distance used by Electron2D.CharacterBody2D.MoveAndSlide.
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.
The non-negative snap distance in world units.
-
System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.ApplyFloorSnapElectron2D.CharacterBody2D.IsOnFloor
Kind: Property
public System.Boolean FloorStopOnSlope { get; set; }Gets or sets whether a standing body should stop on slopes.
The 0.1.0 Preview baseline stores this setting for API completeness. The simple AABB solver does not yet implement full slope stop behavior.
true when slope stop behavior is requested; otherwise, false.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.FloorConstantSpeed
Kind: Property
public System.Int32 MaxSlides { get; set; }Gets or sets the maximum number of slide iterations for Electron2D.CharacterBody2D.MoveAndSlide.
Each iteration consumes the remaining motion after a collision by sliding it along the collision normal.
A positive number of slide iterations.
-
System.ArgumentOutOfRangeException: Thrown when the assigned value is less than or equal to zero.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.MoveAndSlide
Kind: Property
public Electron2D.CharacterBody2D.MotionModeEnum MotionMode { get; set; }Gets or sets the motion mode used by Electron2D.CharacterBody2D.MoveAndSlide.
Electron2D.CharacterBody2D.MotionModeEnum.Grounded classifies collisions into floor,
wall and ceiling. Electron2D.CharacterBody2D.MotionModeEnum.Floating treats slide
collisions as walls.
The current Electron2D.CharacterBody2D.MotionModeEnum.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnFloorElectron2D.CharacterBody2D.IsOnWall
Kind: Property
public System.UInt32 PlatformFloorLayers { get; set; }Gets or sets the layers treated as moving floor platforms.
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.
A bit mask matched against Electron2D.CollisionObject2D.CollisionLayer.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetPlatformVelocityElectron2D.CharacterBody2D.PlatformWallLayers
Kind: Property
public Electron2D.CharacterBody2D.PlatformOnLeaveEnum PlatformOnLeave { get; set; }Gets or sets how platform velocity should be handled when leaving a platform.
The 0.1.0 Preview baseline stores this setting for API completeness. Complex platform leave velocity application is reserved for a later solver pass.
The selected Electron2D.CharacterBody2D.PlatformOnLeaveEnum policy.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetPlatformVelocity
Kind: Property
public System.UInt32 PlatformWallLayers { get; set; }Gets or sets the layers treated as moving wall platforms.
When a wall collision occurs and the collider layer is included in this
mask, Electron2D.CharacterBody2D.GetPlatformVelocity returns the collider velocity.
A bit mask matched against Electron2D.CollisionObject2D.CollisionLayer.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetPlatformVelocityElectron2D.CharacterBody2D.PlatformFloorLayers
Kind: Property
public System.Single SafeMargin { get; set; }Gets or sets the safe margin used by Electron2D.CharacterBody2D.MoveAndSlide.
The managed AABB solver expands target bounds by this margin before sweeping the body.
The non-negative collision margin in world units.
-
System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.PhysicsBody2D.MoveAndCollide(Electron2D.Vector2,System.Boolean,System.Single,System.Boolean)
Kind: Property
public System.Boolean SlideOnCeiling { get; set; }Gets or sets whether the body should slide along ceilings.
When this property is false, a ceiling collision clears the
vertical component of Electron2D.CharacterBody2D.Velocity in the current baseline.
true to allow ceiling slide response; otherwise, false.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnCeiling
Kind: Property
public Electron2D.Vector2 UpDirection { get; set; }Gets or sets the up direction used to classify floor, wall and ceiling collisions.
Floor, wall and ceiling classification compares collision normals against
this direction and Electron2D.CharacterBody2D.FloorMaxAngle.
A finite non-zero vector. The setter stores the normalized direction.
-
System.ArgumentOutOfRangeException: Thrown when the assigned value is zero or contains non-finite components.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.FloorMaxAngleElectron2D.CharacterBody2D.GetFloorAngle(System.Nullable{Electron2D.Vector2})
Kind: Property
public Electron2D.Vector2 Velocity { get; set; }Gets or sets the velocity used by Electron2D.CharacterBody2D.MoveAndSlide.
Electron2D.CharacterBody2D.MoveAndSlide consumes this value using the fixed physics
tick of 1/60 seconds and updates it after slide collisions.
The velocity in units per second.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetRealVelocityElectron2D.CharacterBody2D.MoveAndSlide
Kind: Property
public System.Single WallMinSlideAngle { get; set; }Gets or sets the minimum slide angle for walls.
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.
The non-negative angle in radians.
-
System.ArgumentOutOfRangeException: Thrown when the assigned value is negative or not finite.
This property is not synchronized. Mutate it on the main scene thread.
This property is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnWall
Kind: Constructor
public Electron2D.CharacterBody2D()Initializes a new instance of the Electron2D.CharacterBody2D class.
New instances start with zero velocity, upward floor classification and the managed axis-aligned bounding-box movement baseline.
This constructor is not synchronized. Create nodes on the main scene thread.
This constructor is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D
Kind: Method
public System.Void ApplyFloorSnap()()Applies floor snapping immediately using Electron2D.CharacterBody2D.FloorSnapLength.
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.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.FloorSnapLengthElectron2D.CharacterBody2D.MoveAndSlide
Kind: Method
public System.Single GetFloorAngle(Electron2D.Vector2?)(Electron2D.Vector2? upDirection)Gets the angle of the last floor collision.
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.
-
upDirection: Optional up direction used as reference.
The floor angle in radians, or 0 when no floor collision exists.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetFloorNormalElectron2D.CharacterBody2D.IsOnFloor
Kind: Method
public Electron2D.Vector2 GetFloorNormal()()Gets the normal of the last floor collision.
This value is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call.
The floor normal, or Electron2D.Vector2.Zero when not on floor.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetFloorAngle(System.Nullable{Electron2D.Vector2})Electron2D.CharacterBody2D.IsOnFloor
Kind: Method
public Electron2D.Vector2 GetLastMotion()()Gets the last motion applied by Electron2D.CharacterBody2D.MoveAndSlide.
The value is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call
and accumulates the travel applied by slide and snap movement.
The last slide motion.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetPositionDelta
Kind: Method
public Electron2D.KinematicCollision2D GetLastSlideCollision()()Gets the last slide collision.
The returned collision object belongs to the data collected during the
most recent Electron2D.CharacterBody2D.MoveAndSlide call.
The last slide collision, or null when there are no slide collisions.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetSlideCollision(System.Int32)Electron2D.CharacterBody2D.GetSlideCollisionCount
Kind: Method
public Electron2D.Vector2 GetPlatformVelocity()()Gets the velocity of the platform currently treated as floor or wall.
The baseline reads Electron2D.StaticBody2D.ConstantLinearVelocity from
floor or wall colliders whose layer is included in the relevant platform
mask.
The platform velocity, or Electron2D.Vector2.Zero when none is tracked.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.PlatformFloorLayersElectron2D.CharacterBody2D.PlatformWallLayers
Kind: Method
public Electron2D.Vector2 GetPositionDelta()()Gets the position delta applied by the last Electron2D.CharacterBody2D.MoveAndSlide call.
The value is the difference between Electron2D.Node2D.Position before
and after the last slide call.
The last position delta.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetLastMotionElectron2D.CharacterBody2D.GetRealVelocity
Kind: Method
public Electron2D.Vector2 GetRealVelocity()()Gets the effective velocity from the last applied position delta.
The value is Electron2D.CharacterBody2D.GetPositionDelta divided by the fixed physics
tick used by the 0.1.0 Preview baseline.
The last real velocity.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetPositionDeltaElectron2D.CharacterBody2D.Velocity
Kind: Method
public Electron2D.KinematicCollision2D GetSlideCollision(System.Int32)(System.Int32 slideIdx)Gets a slide collision by index.
Valid indices are in the range 0 through
GetSlideCollisionCount() - 1. Out-of-range indices return
null instead of throwing.
-
slideIdx: The zero-based slide collision index.
The slide collision, or null when the index is outside the current range.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetLastSlideCollisionElectron2D.CharacterBody2D.GetSlideCollisionCount
Kind: Method
public System.Int32 GetSlideCollisionCount()()Gets the number of slide collisions from the last Electron2D.CharacterBody2D.MoveAndSlide call.
The count is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call.
The slide collision count.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetSlideCollision(System.Int32)
Kind: Method
public Electron2D.Vector2 GetWallNormal()()Gets the normal of the last wall collision.
This value is reset at the start of each Electron2D.CharacterBody2D.MoveAndSlide call.
The wall normal, or Electron2D.Vector2.Zero when not on wall.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnWall
Kind: Method
public System.Boolean IsOnCeiling()()Checks whether the last slide movement touched a ceiling.
The value describes the most recent Electron2D.CharacterBody2D.MoveAndSlide call and
is reset before the next slide pass.
true when on ceiling; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnCeilingOnlyElectron2D.CharacterBody2D.SlideOnCeiling
Kind: Method
public System.Boolean IsOnCeilingOnly()()Checks whether the last slide movement touched only a ceiling.
This method returns false if the last slide movement also touched
a floor or wall.
true when only ceiling state is active; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnCeiling
Kind: Method
public System.Boolean IsOnFloor()()Checks whether the last slide movement touched a floor.
Floor state is classified with Electron2D.CharacterBody2D.UpDirection and
Electron2D.CharacterBody2D.FloorMaxAngle when Electron2D.CharacterBody2D.MotionMode is
Electron2D.CharacterBody2D.MotionModeEnum.Grounded.
true when on floor; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetFloorNormalElectron2D.CharacterBody2D.IsOnFloorOnly
Kind: Method
public System.Boolean IsOnFloorOnly()()Checks whether the last slide movement touched only a floor.
This method returns false if the last slide movement also touched
a wall or ceiling.
true when only floor state is active; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnFloor
Kind: Method
public System.Boolean IsOnWall()()Checks whether the last slide movement touched a wall.
Wall state is set for slide collisions that are neither floor nor ceiling in grounded mode, and for all slide collisions in floating mode.
true when on wall; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetWallNormalElectron2D.CharacterBody2D.IsOnWallOnly
Kind: Method
public System.Boolean IsOnWallOnly()()Checks whether the last slide movement touched only a wall.
This method returns false if the last slide movement also touched
a floor or ceiling.
true when only wall state is active; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.IsOnWall
Kind: Method
public System.Boolean MoveAndSlide()()Moves the body using Electron2D.CharacterBody2D.Velocity and slides along collisions.
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.
true when at least one collision happened; otherwise, false.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CharacterBody2D.GetSlideCollision(System.Int32)Electron2D.CharacterBody2D.VelocityElectron2D.PhysicsBody2D.MoveAndCollide(Electron2D.Vector2,System.Boolean,System.Single,System.Boolean)
Electron2D 0.1.0 Preview API reference. Generated from 175 public runtime types.