platformer
Classes | Public Member Functions | Public Attributes | Protected Attributes | List of all members
UnityPlatformer.MovingPlatform Class Reference

Moving Platform Tile More...

Inheritance diagram for UnityPlatformer.MovingPlatform:
UnityPlatformer.RaycastController UnityPlatformer.IUpdateEntity

Classes

struct  PassengerMovement
 Struct to store information about passenger movement More...
 

Public Member Functions

delegate void PassengerEvent (Transform transform)
 callback call when passenter enter/leave More...
 
delegate void WaypointEvent (int index)
 callback call when reach any waypoint More...
 
override void Start ()
 Setup initial state More...
 
void Stop ()
 Stop MovingPlatform More...
 
void StopOn (int waypoints)
 TODO More...
 
void Resume ()
 Resume movement with default speed More...
 
void Reverse ()
 Reverse waypoints, current waypoint and percentBetweenWaypoints This is used when reach the end, so we don't need handle both logics More...
 
bool IsStopped ()
 Reverse waypoints, current waypoint and percentBetweenWaypoints This is used when reach the end, so we don't need handle both logics More...
 
virtual void LatePlatformerUpdate (float delta)
 Do nothing More...
 
void PlatformerUpdate (float delta)
 Get passenger list, pre update, move and post update More...
 
void DoAction (MovingPlatformActions action)
 Perform an action over MovingPlatform like: Resume, stop, reverse.... More...
 
override void OnEnable ()
 notify UpdateManager More...
 
- Public Member Functions inherited from UnityPlatformer.RaycastController
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

LayerMask passengerMask
 Mask of things that can be a passanger More...
 
Line path
 Path that MovingPlatform will follow More...
 
float speed = 2
 Speed along the path More...
 
bool cyclic = false
 true: MovingPlatform will be looping false: MovingPlatform will go back and forth More...
 
float waitTime = 0
 Delay after each waypoint More...
 
float easeAmount = 0
 Ease movement More...
 
bool disableDownRayCast = false
 downcast can move Character in unexpected manners but it's also necessary for one-way-moving-platforms... TODO kill player? More...
 
bool startStopped = false
 Initial state stop? More...
 
WaypointEvent onWaypointEvent
 Called just after select next waypoint and before apply waitTime More...
 
PassengerEvent onEnterPassenger
 Called when a Character start being a passenger More...
 
PassengerEvent onExitPassenger
 Called when a Character is not longer a passenger More...
 
Action onStop
 callback call when MovingPlatform is stopped More...
 
Action onResume
 callback call when MovingPlatform is resume More...
 
Vector3 [] globalWaypoints
 waypoints list taken from path More...
 
- Public Attributes inherited from UnityPlatformer.RaycastController
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...
 

Protected Attributes

int fromWaypointIndex
 current waypoint index More...
 
float percentBetweenWaypoints
 current percentage (0-1) between previous/next waypoints More...
 
float nextMoveTime
 time since last waypoint start, used to calculate (waitTime) delay More...
 
List< PassengerMovementpassengerMovement
 List of passengers to move More...
 
List< PassengerMovementpPassengerMovement
 List of previous passengers More...
 
HashSet< Transform > prevPassengers = null
 List of passengers to moved More...
 
float currentSpeed
 Current speed More...
 
Vector3 lastPosition
 Last position More...
 

Additional Inherited Members

- Properties inherited from UnityPlatformer.RaycastController
Vector3 center [get]
 Collider center in world space More...
 

Detailed Description

Moving Platform Tile

Member Function Documentation

◆ DoAction()

void UnityPlatformer.MovingPlatform.DoAction ( MovingPlatformActions  action)
inline

Perform an action over MovingPlatform like: Resume, stop, reverse....

◆ IsStopped()

bool UnityPlatformer.MovingPlatform.IsStopped ( )
inline

Reverse waypoints, current waypoint and percentBetweenWaypoints This is used when reach the end, so we don't need handle both logics

◆ LatePlatformerUpdate()

virtual void UnityPlatformer.MovingPlatform.LatePlatformerUpdate ( float  delta)
inlinevirtual

Do nothing

Implements UnityPlatformer.IUpdateEntity.

◆ OnEnable()

override void UnityPlatformer.MovingPlatform.OnEnable ( )
inlinevirtual

◆ PassengerEvent()

delegate void UnityPlatformer.MovingPlatform.PassengerEvent ( Transform  transform)

callback call when passenter enter/leave

◆ PlatformerUpdate()

void UnityPlatformer.MovingPlatform.PlatformerUpdate ( float  delta)
inline

Get passenger list, pre update, move and post update

Implements UnityPlatformer.IUpdateEntity.

◆ Resume()

void UnityPlatformer.MovingPlatform.Resume ( )
inline

Resume movement with default speed

◆ Reverse()

void UnityPlatformer.MovingPlatform.Reverse ( )
inline

Reverse waypoints, current waypoint and percentBetweenWaypoints This is used when reach the end, so we don't need handle both logics

◆ Start()

override void UnityPlatformer.MovingPlatform.Start ( )
inlinevirtual

Setup initial state

Reimplemented from UnityPlatformer.RaycastController.

◆ Stop()

void UnityPlatformer.MovingPlatform.Stop ( )
inline

◆ StopOn()

void UnityPlatformer.MovingPlatform.StopOn ( int  waypoints)
inline

TODO

◆ WaypointEvent()

delegate void UnityPlatformer.MovingPlatform.WaypointEvent ( int  index)

callback call when reach any waypoint

Member Data Documentation

◆ currentSpeed

float UnityPlatformer.MovingPlatform.currentSpeed
protected

Current speed

◆ cyclic

bool UnityPlatformer.MovingPlatform.cyclic = false

true: MovingPlatform will be looping false: MovingPlatform will go back and forth

◆ disableDownRayCast

bool UnityPlatformer.MovingPlatform.disableDownRayCast = false

downcast can move Character in unexpected manners but it's also necessary for one-way-moving-platforms... TODO kill player?

◆ easeAmount

float UnityPlatformer.MovingPlatform.easeAmount = 0

Ease movement

◆ fromWaypointIndex

int UnityPlatformer.MovingPlatform.fromWaypointIndex
protected

current waypoint index

◆ globalWaypoints

Vector3 [] UnityPlatformer.MovingPlatform.globalWaypoints

waypoints list taken from path

◆ lastPosition

Vector3 UnityPlatformer.MovingPlatform.lastPosition
protected

Last position

◆ nextMoveTime

float UnityPlatformer.MovingPlatform.nextMoveTime
protected

time since last waypoint start, used to calculate (waitTime) delay

◆ onEnterPassenger

PassengerEvent UnityPlatformer.MovingPlatform.onEnterPassenger

Called when a Character start being a passenger

◆ onExitPassenger

PassengerEvent UnityPlatformer.MovingPlatform.onExitPassenger

Called when a Character is not longer a passenger

◆ onResume

Action UnityPlatformer.MovingPlatform.onResume

callback call when MovingPlatform is resume

◆ onStop

Action UnityPlatformer.MovingPlatform.onStop

callback call when MovingPlatform is stopped

◆ onWaypointEvent

WaypointEvent UnityPlatformer.MovingPlatform.onWaypointEvent

Called just after select next waypoint and before apply waitTime

◆ passengerMask

LayerMask UnityPlatformer.MovingPlatform.passengerMask

Mask of things that can be a passanger

◆ passengerMovement

List<PassengerMovement> UnityPlatformer.MovingPlatform.passengerMovement
protected

List of passengers to move

◆ path

Line UnityPlatformer.MovingPlatform.path

Path that MovingPlatform will follow

◆ percentBetweenWaypoints

float UnityPlatformer.MovingPlatform.percentBetweenWaypoints
protected

current percentage (0-1) between previous/next waypoints

◆ pPassengerMovement

List<PassengerMovement> UnityPlatformer.MovingPlatform.pPassengerMovement
protected

List of previous passengers

◆ prevPassengers

HashSet<Transform> UnityPlatformer.MovingPlatform.prevPassengers = null
protected

List of passengers to moved

◆ speed

float UnityPlatformer.MovingPlatform.speed = 2

Speed along the path

◆ startStopped

bool UnityPlatformer.MovingPlatform.startStopped = false

Initial state stop?

◆ waitTime

float UnityPlatformer.MovingPlatform.waitTime = 0

Delay after each waypoint


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