platformer
|
Raycast helper More...
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... | |
Raycast helper
|
inline |
Recalculate distance between rays (horizontalRaySpacing & verticalRaySpacing)
|
inline |
Return RaycastHit2D of Raycasting at bottom center.
|
inline |
Iterate over all feet/vertical rays
|
inline |
Iterate over all head/vertical rays
|
inline |
Iterate over all left/horizontal rays
|
inline |
Iterate over all right/horizontal rays
|
inline |
Return gravity aware bottom left
|
inline |
Return gravity aware bottom right
|
inline |
Return gravity aware down Vector2
|
inline |
Return RaycastHit2D of Raycasting at bottom left.
|
inlinevirtual |
Recalculate everything
Reimplemented in UnityPlatformer.Character, UnityPlatformer.MovingPlatform, UnityPlatformer.PlatformerCollider2D, and UnityPlatformer.Enemy.
|
inline |
Call Physics2D.Raycast and Draw the ray to debug
delegate void UnityPlatformer.RaycastController.RayItr | ( | ref RaycastHit2D | hit, |
ref Vector3 | velocity, | ||
int | dir, | ||
int | idx | ||
) |
Callback for iterate rays
|
inline |
Return RaycastHit2D of Raycasting at bottom right.
|
inlinevirtual |
initialize cached properties
Reimplemented in UnityPlatformer.PlatformerCollider2D, UnityPlatformer.MovingPlatform, UnityPlatformer.AIPatrol, and UnityPlatformer.Enemy.
|
inline |
Recalculate shrinked the bounds
|
inline |
Recalculate raycastOrigins
|
inline |
Return RaycastHit2D of Raycasting at given index
LayerMask UnityPlatformer.RaycastController.collisionMask |
Static geometry mask
bool UnityPlatformer.RaycastController.debug = false |
Enable drawing debug information, this has performance impact
float UnityPlatformer.RaycastController.height |
Collider real height
int UnityPlatformer.RaycastController.horizontalRayCount = 4 |
How many rays to check horizontal collisions
Vector3 UnityPlatformer.RaycastController.localCenter |
Collider center in local space
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
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
int UnityPlatformer.RaycastController.verticalRayCount = 4 |
How many rays to check vertical collisions
|
get |
Collider center in world space