platformer
Classes | Public Member Functions | Public Attributes | Properties | List of all members
UnityPlatformer.RaycastController Class Reference

Raycast helper More...

Inheritance diagram for UnityPlatformer.RaycastController:
UnityPlatformer.MovingPlatform UnityPlatformer.PlatformerCollider2D UnityPlatformer.Character UnityPlatformer.Enemy UnityPlatformer.StaticCharacter UnityPlatformer.AICannon UnityPlatformer.AIPatrol UnityPlatformer.AIJumper

Classes

struct  RaycastOrigins
 Raycast Origins More...
 

Public Member Functions

virtual void Start ()
 initialize cached properties More...
 
virtual void OnEnable ()
 Recalculate everything More...
 
void UpdateInnerBounds ()
 Recalculate shrinked the bounds More...
 
void UpdateRaycastOrigins ()
 Recalculate raycastOrigins More...
 
void CalculateRaySpacing ()
 Recalculate distance between rays (horizontalRaySpacing & verticalRaySpacing) More...
 
RaycastHit2D Raycast (Vector2 origin, Vector2 direction, float rayLength, int mask, Color? color=null)
 Call Physics2D.Raycast and Draw the ray to debug More...
 
RaycastHit2D VerticalRay (float directionY, int index, float rayLength, ref Vector3 velocity, Color? c=null)
 Return RaycastHit2D of Raycasting at given index More...
 
RaycastHit2D FeetRay (float rayLength, LayerMask mask)
 Return RaycastHit2D of Raycasting at bottom center. More...
 
delegate void RayItr (ref RaycastHit2D hit, ref Vector3 velocity, int dir, int idx)
 Callback for iterate rays More...
 
void ForeachRightRay (float rayLength, ref Vector3 velocity, RayItr itr)
 Iterate over all right/horizontal rays More...
 
void ForeachLeftRay (float rayLength, ref Vector3 velocity, RayItr itr)
 Iterate over all left/horizontal rays More...
 
void ForeachHeadRay (float rayLength, ref Vector3 velocity, RayItr itr, bool checkGravitySwap=true)
 Iterate over all head/vertical rays More...
 
void ForeachFeetRay (float rayLength, ref Vector3 velocity, RayItr itr, bool checkGravitySwap=true)
 Iterate over all feet/vertical rays More...
 
Vector2 GetDownVector ()
 Return gravity aware down Vector2 More...
 
Vector3 GetBottomLeft ()
 Return gravity aware bottom left More...
 
Vector3 GetBottomRight ()
 Return gravity aware bottom right More...
 
RaycastHit2D LeftFeetRay (float rayLength, Vector3 velocity)
 Return RaycastHit2D of Raycasting at bottom left. More...
 
RaycastHit2D RightFeetRay (float rayLength, Vector3 velocity)
 Return RaycastHit2D of Raycasting at bottom right. More...
 

Public Attributes

bool debug = false
 Enable drawing debug information, this has performance impact More...
 
LayerMask collisionMask
 Static geometry mask More...
 
float minDistanceToEnv = 0.1f
 How far from then env the Character must be. More...
 
float skinWidth = 0.2f
 Defines how far in from the edges of the collider rays are we going to cast from. More...
 
int horizontalRayCount = 4
 How many rays to check horizontal collisions More...
 
int verticalRayCount = 4
 How many rays to check vertical collisions More...
 
float height
 Collider real height More...
 
Vector3 localCenter
 Collider center in local space More...
 

Properties

Vector3 center [get]
 Collider center in world space More...
 

Detailed Description

Raycast helper

Member Function Documentation

◆ CalculateRaySpacing()

void UnityPlatformer.RaycastController.CalculateRaySpacing ( )
inline

Recalculate distance between rays (horizontalRaySpacing & verticalRaySpacing)

◆ FeetRay()

RaycastHit2D UnityPlatformer.RaycastController.FeetRay ( float  rayLength,
LayerMask  mask 
)
inline

Return RaycastHit2D of Raycasting at bottom center.

◆ ForeachFeetRay()

void UnityPlatformer.RaycastController.ForeachFeetRay ( float  rayLength,
ref Vector3  velocity,
RayItr  itr,
bool  checkGravitySwap = true 
)
inline

Iterate over all feet/vertical rays

◆ ForeachHeadRay()

void UnityPlatformer.RaycastController.ForeachHeadRay ( float  rayLength,
ref Vector3  velocity,
RayItr  itr,
bool  checkGravitySwap = true 
)
inline

Iterate over all head/vertical rays

◆ ForeachLeftRay()

void UnityPlatformer.RaycastController.ForeachLeftRay ( float  rayLength,
ref Vector3  velocity,
RayItr  itr 
)
inline

Iterate over all left/horizontal rays

◆ ForeachRightRay()

void UnityPlatformer.RaycastController.ForeachRightRay ( float  rayLength,
ref Vector3  velocity,
RayItr  itr 
)
inline

Iterate over all right/horizontal rays

◆ GetBottomLeft()

Vector3 UnityPlatformer.RaycastController.GetBottomLeft ( )
inline

Return gravity aware bottom left

◆ GetBottomRight()

Vector3 UnityPlatformer.RaycastController.GetBottomRight ( )
inline

Return gravity aware bottom right

◆ GetDownVector()

Vector2 UnityPlatformer.RaycastController.GetDownVector ( )
inline

Return gravity aware down Vector2

◆ LeftFeetRay()

RaycastHit2D UnityPlatformer.RaycastController.LeftFeetRay ( float  rayLength,
Vector3  velocity 
)
inline

Return RaycastHit2D of Raycasting at bottom left.

◆ OnEnable()

virtual void UnityPlatformer.RaycastController.OnEnable ( )
inlinevirtual

◆ Raycast()

RaycastHit2D UnityPlatformer.RaycastController.Raycast ( Vector2  origin,
Vector2  direction,
float  rayLength,
int  mask,
Color?  color = null 
)
inline

Call Physics2D.Raycast and Draw the ray to debug

◆ RayItr()

delegate void UnityPlatformer.RaycastController.RayItr ( ref RaycastHit2D  hit,
ref Vector3  velocity,
int  dir,
int  idx 
)

Callback for iterate rays

◆ RightFeetRay()

RaycastHit2D UnityPlatformer.RaycastController.RightFeetRay ( float  rayLength,
Vector3  velocity 
)
inline

Return RaycastHit2D of Raycasting at bottom right.

◆ Start()

virtual void UnityPlatformer.RaycastController.Start ( )
inlinevirtual

◆ UpdateInnerBounds()

void UnityPlatformer.RaycastController.UpdateInnerBounds ( )
inline

Recalculate shrinked the bounds

◆ UpdateRaycastOrigins()

void UnityPlatformer.RaycastController.UpdateRaycastOrigins ( )
inline

Recalculate raycastOrigins

◆ VerticalRay()

RaycastHit2D UnityPlatformer.RaycastController.VerticalRay ( float  directionY,
int  index,
float  rayLength,
ref Vector3  velocity,
Color?  c = null 
)
inline

Return RaycastHit2D of Raycasting at given index

Member Data Documentation

◆ collisionMask

LayerMask UnityPlatformer.RaycastController.collisionMask

Static geometry mask

◆ debug

bool UnityPlatformer.RaycastController.debug = false

Enable drawing debug information, this has performance impact

◆ height

float UnityPlatformer.RaycastController.height

Collider real height

◆ horizontalRayCount

int UnityPlatformer.RaycastController.horizontalRayCount = 4

How many rays to check horizontal collisions

◆ localCenter

Vector3 UnityPlatformer.RaycastController.localCenter

Collider center in local space

◆ minDistanceToEnv

float UnityPlatformer.RaycastController.minDistanceToEnv = 0.1f

How far from then env the Character must be.

NOTE: must be less than skinWidth, to allow continuous ground contact

◆ skinWidth

float UnityPlatformer.RaycastController.skinWidth = 0.2f

Defines how far in from the edges of the collider rays are we going to cast from.

NOTE: This value must be greater than minDistanceToEnv

◆ verticalRayCount

int UnityPlatformer.RaycastController.verticalRayCount = 4

How many rays to check vertical collisions

Property Documentation

◆ center

Vector3 UnityPlatformer.RaycastController.center
get

Collider center in world space


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