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 CharacterController2D

Remarks

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 SlopeLimit

The steepest slope it stands on and walks up, in degrees from level; steeper is a wall.

StepOffset

public float StepOffset

The highest ledge it steps up onto as it walks, in meters.

SnapToGround

public float SnapToGround

How 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 IsGrounded

Whether it stood on ground after the last step: something no steeper than CharacterController2D.SlopeLimit under it.

GroundNormal

public Vector2 GroundNormal

The normal of the ground it stood on, a unit long; zero off the ground.

Ground

public ulong Ground

The body it stood on — the entity with its Rigidbody 2D, or ground — or 0.

OnWall

public bool OnWall

Whether something steeper than CharacterController2D.SlopeLimit was beside it after the last step.

OnCeiling

public bool OnCeiling

Whether something was over it after the last step, facing down within CharacterController2D.SlopeLimit.