2D Platform Controller  v1.7.0
Autogenerated code documentation for the 2D Platform Controller.
 All Classes Functions Variables Properties
RaycastCharacterController Class Reference

Raycast character controller a controller for 2D platform games. More...

Inherits MonoBehaviour.

Inherited by EnemyBounceAndFall.

Public Member Functions

delegate void CharacterControllerEventDelegate (CharacterState state, CharacterState previousState)
 
void SetDrag (float drag)
 Sets the drag for the current frame. Use this to implement slippery or sticky platforms. More...
 
void Dismount (Ladder ladder)
 Dismount the specified Ladder. This is used to stop autosticking to the same ladder you just dismounted. More...
 
bool Unparent (Platform platform)
 Force the character to unparent from the given object. More...
 
void ForceSetCharacterState (CharacterState state)
 Forces the state of the character to be the provided value. More...
 
bool IsGrounded (float offset, bool includeClimables=true)
 Determines whether this character is grounded. More...
 
void SwitchColliders ()
 Switches the colliders direction. This is a default implementation a direction checker may choose to do something different. This is primarily for assymetrical characters. More...
 
void Stun (float stunTime)
 Stuns the character so it cannot move for the specified time. The exact definition of "cannot move" depends on the stun settings. A stun animation event will also be sent. More...
 
void DoCrouch ()
 

Public Attributes

RaycastCollider[] feetColliders
 The feet colliders. These colliders push the characters upwards and also hnadle climbing. More...
 
RaycastCollider[] headColliders
 The head colliders. These characters push the chraacter down when the head is hit. More...
 
RaycastCollider[] sides
 The sides. These colliders push the character left and right when they hit obstacles. More...
 
MovementDetails movement
 The movement details, controls how the chracter moves on the ground. More...
 
JumpDetails jump
 The jump details. Controls how the character moves in the air. More...
 
WallDetails wall
 The wall details. Controls how the character interacts with walls. More...
 
SlopeDetails slopes
 The slopes details. Controls how the character handles sloped platforms. More...
 
ClimbDetails climbing
 The climbing details. Controls how a chracter handles climbables like ropes and ladders. More...
 
LedgeDetails ledgeHanging
 The ledge hanging details. Controls how a character handles ledges. More...
 
CrouchDetails crouch
 The crouch details. Controls how a chracter handles crouching. More...
 
StunType stun
 The type of stun to apply. More...
 
int backgroundLayer
 The layer of normal objects that the chracter cannot pass through. More...
 
int passThroughLayer
 The layer of object which the chracter can jump through but can not fall through. More...
 
int climableLayer
 The layer of objects the character can climb. More...
 
bool controllerActive = true
 Is the controller active. If this is false nothing will move. Use for cutscenes, static animations character death, pause, etc. More...
 
bool sendAnimationEventsEachFrame = false
 If true the animation events will be sent constantly, if false (default) only changes of state will be sent. More...
 
float groundedLookAhead = 0.25f
 How far to look ahead when considering if this character is grounded. More...
 
float maxSpeedForIdle = 0.1f
 If the character is moving slower than this they will be considered idle. More...
 
RaycastCharacterInput characterInput
 The character input that controls this character. More...
 
DirectionChecker directionChecker
 Assign a direction checker if you want to do one of two things. 1) Determine the way the character is facing using a mechanism other than the default (for example based on mouse position) OR 2) Switch or change colliders based on the direction the character is facing (for example if you have an assymetrical character). More...
 

Static Public Attributes

static float maxFrameTime = 0.033f
 The maximum time a frame can take. Smaller values allow your character to move faster, larger values will tend to make lag less apparent. Static so it is the same across all components. WARNING: If this is too large your character can fall through the ground, or move through small platforms. More...
 

Protected Member Functions

void UpdateAnimation ()
 Updates the animation state and sends an event. More...
 
void MoveInXDirection (bool grounded)
 
void MoveInYDirection (bool grounded)
 

Protected Attributes

float frameTime
 
float stunTimer
 

Properties

bool IsClimbingUpOrDown [get]
 Gets a value indicating whether the cahracter is climbing up or down (as opposed to just holding on to a climbable). Value is undefined if StartedClimbing = false; More...
 
Vector2 Velocity [get, set]
 Gets or sets the velocity. You can interact with this directly in order to create (for example) escalators or coveyer belts. More...
 
bool StartedClimbing [get]
 Gets a value indicating whether this RaycastCharacterController has started climbing a climbable More...
 
CharacterState State [get, set]
 Get the animation state of the character. You can use this for animation as an alternative to listening to events. More...
 
Platform MyParent [get]
 Gets the parent platform More...
 
float FallThroughTimer [get, set]
 Sets the fall through timer (used by passthrough platforms). More...
 
int CurrentDirection [get]
 The current direction being faced. 0 = NONE, 1 = RIGHT -1 = LEFT. Uses a direction checker if one is assigned else the character will face the direction that is being held or the direction they are moving in. More...
 
static float FrameTime [get]
 Gets the frame time. More...
 
int GroundedFeetCount [get]
 Returns how many of the feet colliders are on the ground. You can use this to play a "teeter" animation. More...
 
bool IsLedgeHanging [get]
 Gets a value indicating if the character is ledge hanging. More...
 
RC_Direction LedgeHangDirection [get]
 Gets a value indicating the direciton the character is hanging. Value has no meaning if the character is not ledge hanging. More...
 

Events

CharacterControllerEventDelegate CharacterAnimationEvent
 

Detailed Description

Raycast character controller a controller for 2D platform games.

Member Function Documentation

void RaycastCharacterController.Dismount ( Ladder  ladder)

Dismount the specified Ladder. This is used to stop autosticking to the same ladder you just dismounted.

Parameters
ladderLadder control to dismount.
void RaycastCharacterController.ForceSetCharacterState ( CharacterState  state)

Forces the state of the character to be the provided value.

Parameters
stateState.
bool RaycastCharacterController.IsGrounded ( float  offset,
bool  includeClimables = true 
)

Determines whether this character is grounded.

Returns
true if this instance is grounded; otherwise, false.
Parameters
offsetHow much to look ahead from the feet colliders when determining if the character is grounded.
void RaycastCharacterController.MoveInXDirection ( bool  grounded)
protected

Update wall slide

void RaycastCharacterController.SetDrag ( float  drag)

Sets the drag for the current frame. Use this to implement slippery or sticky platforms.

Parameters
dragDrag for the current frame.
void RaycastCharacterController.Stun ( float  stunTime)

Stuns the character so it cannot move for the specified time. The exact definition of "cannot move" depends on the stun settings. A stun animation event will also be sent.

Parameters
stunTimeStun time.
void RaycastCharacterController.SwitchColliders ( )

Switches the colliders direction. This is a default implementation a direction checker may choose to do something different. This is primarily for assymetrical characters.

bool RaycastCharacterController.Unparent ( Platform  platform)

Force the character to unparent from the given object.

Returns
true if the object was parented to the supplied platform and then successfully unparented.
Parameters
platformThe platform to unparent from.
void RaycastCharacterController.UpdateAnimation ( )
protected

Updates the animation state and sends an event.

Member Data Documentation

int RaycastCharacterController.backgroundLayer

The layer of normal objects that the chracter cannot pass through.

RaycastCharacterInput RaycastCharacterController.characterInput

The character input that controls this character.

int RaycastCharacterController.climableLayer

The layer of objects the character can climb.

ClimbDetails RaycastCharacterController.climbing

The climbing details. Controls how a chracter handles climbables like ropes and ladders.

bool RaycastCharacterController.controllerActive = true

Is the controller active. If this is false nothing will move. Use for cutscenes, static animations character death, pause, etc.

CrouchDetails RaycastCharacterController.crouch

The crouch details. Controls how a chracter handles crouching.

DirectionChecker RaycastCharacterController.directionChecker

Assign a direction checker if you want to do one of two things. 1) Determine the way the character is facing using a mechanism other than the default (for example based on mouse position) OR 2) Switch or change colliders based on the direction the character is facing (for example if you have an assymetrical character).

RaycastCollider [] RaycastCharacterController.feetColliders

The feet colliders. These colliders push the characters upwards and also hnadle climbing.

float RaycastCharacterController.groundedLookAhead = 0.25f

How far to look ahead when considering if this character is grounded.

RaycastCollider [] RaycastCharacterController.headColliders

The head colliders. These characters push the chraacter down when the head is hit.

JumpDetails RaycastCharacterController.jump

The jump details. Controls how the character moves in the air.

LedgeDetails RaycastCharacterController.ledgeHanging

The ledge hanging details. Controls how a character handles ledges.

float RaycastCharacterController.maxFrameTime = 0.033f
static

The maximum time a frame can take. Smaller values allow your character to move faster, larger values will tend to make lag less apparent. Static so it is the same across all components. WARNING: If this is too large your character can fall through the ground, or move through small platforms.

float RaycastCharacterController.maxSpeedForIdle = 0.1f

If the character is moving slower than this they will be considered idle.

MovementDetails RaycastCharacterController.movement

The movement details, controls how the chracter moves on the ground.

int RaycastCharacterController.passThroughLayer

The layer of object which the chracter can jump through but can not fall through.

bool RaycastCharacterController.sendAnimationEventsEachFrame = false

If true the animation events will be sent constantly, if false (default) only changes of state will be sent.

RaycastCollider [] RaycastCharacterController.sides

The sides. These colliders push the character left and right when they hit obstacles.

SlopeDetails RaycastCharacterController.slopes

The slopes details. Controls how the character handles sloped platforms.

StunType RaycastCharacterController.stun

The type of stun to apply.

WallDetails RaycastCharacterController.wall

The wall details. Controls how the character interacts with walls.

Property Documentation

int RaycastCharacterController.CurrentDirection
get

The current direction being faced. 0 = NONE, 1 = RIGHT -1 = LEFT. Uses a direction checker if one is assigned else the character will face the direction that is being held or the direction they are moving in.

float RaycastCharacterController.FallThroughTimer
getset

Sets the fall through timer (used by passthrough platforms).

float RaycastCharacterController.FrameTime
staticget

Gets the frame time.

The frame time.

int RaycastCharacterController.GroundedFeetCount
get

Returns how many of the feet colliders are on the ground. You can use this to play a "teeter" animation.

bool RaycastCharacterController.IsClimbingUpOrDown
get

Gets a value indicating whether the cahracter is climbing up or down (as opposed to just holding on to a climbable). Value is undefined if StartedClimbing = false;

bool RaycastCharacterController.IsLedgeHanging
get

Gets a value indicating if the character is ledge hanging.

RC_Direction RaycastCharacterController.LedgeHangDirection
get

Gets a value indicating the direciton the character is hanging. Value has no meaning if the character is not ledge hanging.

Platform RaycastCharacterController.MyParent
get

Gets the parent platform

bool RaycastCharacterController.StartedClimbing
get

Gets a value indicating whether this RaycastCharacterController has started climbing a climbable

true if started climbing; otherwise, false.

CharacterState RaycastCharacterController.State
getset

Get the animation state of the character. You can use this for animation as an alternative to listening to events.

The current animation state.

Vector2 RaycastCharacterController.Velocity
getset

Gets or sets the velocity. You can interact with this directly in order to create (for example) escalators or coveyer belts.

The velocity.


The documentation for this class was generated from the following file: