Platformer Pro  2.3.2
A platform game kit for Unity.
PlatformerPro.BaseCollisions Class Reference

The base collision behaviour stops the character from passing through obstacles. It is called by most Movement<c> calls after they have finished movement to ensure that the character doesn't penetrate level geometry. Movement More...

Inheritance diagram for PlatformerPro.BaseCollisions:

Public Member Functions

virtual void Init (Character character)
 Initialise this instance. Called by the cahracter on start. More...
 
virtual Vector2 DoCollisions (RaycastType typeMask, int layerMask, int passthroughLayerMask)
 Check for collider penetration of the given types on the given layers and move the character if found. More...
 
virtual bool IsGrounded ()
 Is the character grounded based on the last time collisions were calculated? More...
 

Protected Member Functions

virtual void ResetCollisions ()
 Clear the array of colliders that have received Collide() messages. More...
 
virtual bool HasReceivedCollideMessage (Collider2D collider)
 Determines whether the provided collider has received Collide() message this frame. More...
 
virtual void AddColliderToSentMessageReceivers (Collider2D collider)
 Adds a colldier to the list of colliders that received the Collide() message. More...
 

Protected Attributes

Character character
 Cached reference to the character. More...
 
bool grounded
 Keeps track of the grounded state ccording to the last time collisions were executed. More...
 
float timeToFallFeetDistance
 Calcualte how long it would take to fall feet distance with the current gravity. We use this to control passthrough platform application. More...
 
bool assumeConstantGravityAndFeetDistance
 If gravity and feet length is constant we can do less calculations for passthrough platforms. More...
 
int[] closestColliders
 Keeps track of the closest collisions. More...
 
PlatformCollisionArgs platformCollisionArgs
 The platform collision arguments. Avoid creating a new one each frame. More...
 
Collider2D[] collidersAlreadySentMessages
 An array of colldiers which received an action message this frame. More...
 

Properties

int[] ClosestColliders [get]
 Make closest collisions available so we don't need to calculate twice. More...
 

Detailed Description

The base collision behaviour stops the character from passing through obstacles. It is called by most Movement<c> calls after they have finished movement to ensure that the character doesn't penetrate level geometry. Movement

Member Function Documentation

◆ AddColliderToSentMessageReceivers()

virtual void PlatformerPro.BaseCollisions.AddColliderToSentMessageReceivers ( Collider2D  collider)
protectedvirtual

Adds a colldier to the list of colliders that received the Collide() message.

Parameters
colliderCollider to add.

◆ DoCollisions()

virtual Vector2 PlatformerPro.BaseCollisions.DoCollisions ( RaycastType  typeMask,
int  layerMask,
int  passthroughLayerMask 
)
virtual

Check for collider penetration of the given types on the given layers and move the character if found.

Parameters
typeMaskThe types to consider.
layerMaskThe layers to consider.
Returns
A vector representing the amount of movement applied.

◆ HasReceivedCollideMessage()

virtual bool PlatformerPro.BaseCollisions.HasReceivedCollideMessage ( Collider2D  collider)
protectedvirtual

Determines whether the provided collider has received Collide() message this frame.

Returns
true if the collider has received Collide() message; otherwise, false.
Parameters
colliderCollider.

◆ Init()

virtual void PlatformerPro.BaseCollisions.Init ( Character  character)
virtual

Initialise this instance. Called by the cahracter on start.

Parameters
characterCharacter.

◆ IsGrounded()

virtual bool PlatformerPro.BaseCollisions.IsGrounded ( )
virtual

Is the character grounded based on the last time collisions were calculated?

◆ ResetCollisions()

virtual void PlatformerPro.BaseCollisions.ResetCollisions ( )
protectedvirtual

Clear the array of colliders that have received Collide() messages.

Member Data Documentation

◆ assumeConstantGravityAndFeetDistance

bool PlatformerPro.BaseCollisions.assumeConstantGravityAndFeetDistance
protected

If gravity and feet length is constant we can do less calculations for passthrough platforms.

◆ character

Character PlatformerPro.BaseCollisions.character
protected

Cached reference to the character.

◆ closestColliders

int [] PlatformerPro.BaseCollisions.closestColliders
protected

Keeps track of the closest collisions.

◆ collidersAlreadySentMessages

Collider2D [] PlatformerPro.BaseCollisions.collidersAlreadySentMessages
protected

An array of colldiers which received an action message this frame.

◆ grounded

bool PlatformerPro.BaseCollisions.grounded
protected

Keeps track of the grounded state ccording to the last time collisions were executed.

◆ platformCollisionArgs

PlatformCollisionArgs PlatformerPro.BaseCollisions.platformCollisionArgs
protected

The platform collision arguments. Avoid creating a new one each frame.

◆ timeToFallFeetDistance

float PlatformerPro.BaseCollisions.timeToFallFeetDistance
protected

Calcualte how long it would take to fall feet distance with the current gravity. We use this to control passthrough platform application.

Property Documentation

◆ ClosestColliders

int [] PlatformerPro.BaseCollisions.ClosestColliders
get

Make closest collisions available so we don't need to calculate twice.


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