Scripting API
Scripting API
CharacterController2D
Struct in Abyss.Physics2D, from Abyss.Physics2D.
A character, moved as it is told rather than pushed about as a body is: the Rigidbody 2D on its entity, moved as a Kinematic one whatever its Type, and its Capsule Collider 2D the shape it moves as. Its Rigidbody 2D's LinearVelocity is where it goes — what code sets to walk it and to jump, what the last step left, less what went into a wall or a ceiling and, on the ground, its speed down — and its Gravity Scale how hard it falls, 0 for a game seen from above.
public struct CharacterController2DRemarks
Each fixed step it slides along what it meets instead of going into it: up a slope no steeper than CharacterController2D.SlopeLimit, which it stands on without sliding down; down one steeper; up onto a ledge no higher than CharacterController2D.StepOffset; and down a slope or off a step kept to the ground within CharacterController2D.SnapToGround. Standing on a body that moves — a platform, an elevator — it is carried with it, and keeps the body's velocity as it jumps or walks off. A dynamic body in its way is pushed as the two masses say, its Rigidbody 2D's Mass its own, and what it stands on bears its weight. Other bodies meet it as a Kinematic body: what falls on it rests on it, and triggers and queries find it.
What the last step left — CharacterController2D.IsGrounded, CharacterController2D.Ground, CharacterController2D.OnWall, CharacterController2D.OnCeiling — is what a system reads to decide what the character does next: a jump only from the ground, say.
Fields
SlopeLimit
public float SlopeLimitThe steepest slope it stands on and walks up, in degrees from level; steeper is a wall.
StepOffset
public float StepOffsetThe highest ledge it steps up onto as it walks, in meters.
SnapToGround
public float SnapToGroundHow far below it ground is looked for as it walks down a slope or off a step, in meters, to stay on it.
IsGrounded
public bool IsGroundedWhether it stood on ground after the last step: something no steeper than CharacterController2D.SlopeLimit under it.
GroundNormal
public Vector2 GroundNormalThe normal of the ground it stood on, a unit long; zero off the ground.
Ground
public ulong GroundThe body it stood on — the entity with its Rigidbody 2D, or ground — or 0.
OnWall
public bool OnWallWhether something steeper than CharacterController2D.SlopeLimit was beside it after the last step.
OnCeiling
public bool OnCeilingWhether something was over it after the last step, facing down within CharacterController2D.SlopeLimit.
