C# Class UnityPlatformer.RaycastController

Inheritance: UnityEngine.MonoBehaviour
Mostra file Open project: llafuente/unity-platformer

Public Properties

Property Type Description
collisionMask UnityEngine.LayerMask
horizontalRayCount int
minDistanceToEnv float
skinWidth float
verticalRayCount int

Public Methods

Method Description
CalculateRaySpacing ( ) : void

Recalculate distance between rays (horizontalRaySpacing & verticalRaySpacing)

FeetRay ( float rayLength, LayerMask mask ) : RaycastHit2D

Return RaycastHit2D of Raycasting at bottom center.

ForeachFeetRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void

Iterate over all feet/vertical rays

ForeachHeadRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void

Iterate over all head/vertical rays

ForeachLeftRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void

Iterate over all left/horizontal rays

ForeachRightRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void

Iterate over all right/horizontal rays

LeftFeetRay ( float rayLength, Vector3 velocity ) : RaycastHit2D

Return RaycastHit2D of Raycasting at bottom left.

OnEnable ( ) : void

Recalculate everything

Raycast ( Vector2 origin, Vector2 direction, float rayLength, int mask, Color color = null ) : RaycastHit2D

Call Physics2D.Raycast and Draw the ray to debug

RightFeetRay ( float rayLength, Vector3 velocity ) : RaycastHit2D

Return RaycastHit2D of Raycasting at bottom right.

UpdateInnerBounds ( ) : void

Recalculate shrinked the bounds

UpdateRaycastOrigins ( ) : void

Recalculate raycastOrigins

VerticalRay ( float directionY, int index, float rayLength, Vector3 &velocity, Color c = null ) : RaycastHit2D

Return RaycastHit2D of Raycasting at given index

Method Details

CalculateRaySpacing() public method

Recalculate distance between rays (horizontalRaySpacing & verticalRaySpacing)
public CalculateRaySpacing ( ) : void
return void

FeetRay() public method

Return RaycastHit2D of Raycasting at bottom center.
public FeetRay ( float rayLength, LayerMask mask ) : RaycastHit2D
rayLength float
mask UnityEngine.LayerMask
return UnityEngine.RaycastHit2D

ForeachFeetRay() public method

Iterate over all feet/vertical rays
public ForeachFeetRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void
rayLength float
velocity Vector3
itr RayItr
return void

ForeachHeadRay() public method

Iterate over all head/vertical rays
public ForeachHeadRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void
rayLength float
velocity Vector3
itr RayItr
return void

ForeachLeftRay() public method

Iterate over all left/horizontal rays
public ForeachLeftRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void
rayLength float
velocity Vector3
itr RayItr
return void

ForeachRightRay() public method

Iterate over all right/horizontal rays
public ForeachRightRay ( float rayLength, Vector3 &velocity, RayItr itr ) : void
rayLength float
velocity Vector3
itr RayItr
return void

LeftFeetRay() public method

Return RaycastHit2D of Raycasting at bottom left.
public LeftFeetRay ( float rayLength, Vector3 velocity ) : RaycastHit2D
rayLength float
velocity Vector3
return UnityEngine.RaycastHit2D

OnEnable() public method

Recalculate everything
public OnEnable ( ) : void
return void

Raycast() public method

Call Physics2D.Raycast and Draw the ray to debug
public Raycast ( Vector2 origin, Vector2 direction, float rayLength, int mask, Color color = null ) : RaycastHit2D
origin Vector2
direction Vector2
rayLength float
mask int
color Color
return UnityEngine.RaycastHit2D

RightFeetRay() public method

Return RaycastHit2D of Raycasting at bottom right.
public RightFeetRay ( float rayLength, Vector3 velocity ) : RaycastHit2D
rayLength float
velocity Vector3
return UnityEngine.RaycastHit2D

UpdateInnerBounds() public method

Recalculate shrinked the bounds
public UpdateInnerBounds ( ) : void
return void

UpdateRaycastOrigins() public method

Recalculate raycastOrigins
public UpdateRaycastOrigins ( ) : void
return void

VerticalRay() public method

Return RaycastHit2D of Raycasting at given index
public VerticalRay ( float directionY, int index, float rayLength, Vector3 &velocity, Color c = null ) : RaycastHit2D
directionY float
index int
rayLength float
velocity Vector3
c Color
return UnityEngine.RaycastHit2D

Property Details

collisionMask public_oe property

Static geometry mask
public LayerMask,UnityEngine collisionMask
return UnityEngine.LayerMask

horizontalRayCount public_oe property

How many rays to check horizontal collisions
public int horizontalRayCount
return int

minDistanceToEnv public_oe property

How far from then env the Character must be. NOTE: must be less than skinWidth, to allow continuous ground contact
public float minDistanceToEnv
return float

skinWidth public_oe property

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
public float skinWidth
return float

verticalRayCount public_oe property

How many rays to check vertical collisions
public int verticalRayCount
return int