Corgi Engine  v8.8
MoreMountains.CorgiEngine.AnyHeightOneWayPlatform Class Reference

Add this component to a one way platform (a platform with an edge collider, on the OneWayPlatforms layer) and it will automatically turn its collider on or off based on the player position, letting you easily move it around, and will also let the player collide with it laterally, like a mid height one way platform would, but regardless of its placement or rotation. It's slightly more costly than a regular, static one, but will offer more options too More...

Inheritance diagram for MoreMountains.CorgiEngine.AnyHeightOneWayPlatform:
MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Member Functions

virtual void Initialization ()
 Stores the collider and computes its points' world coordinates More...
 
virtual void GrabTargetPlayer ()
 Stores the target player character More...
 
virtual void CacheColliderWorldCoordinates ()
 Stores the positions of the platform's edges More...
 

Public Attributes

int PlayerID = 0
 the ID of the target Player to consider for this platform - usually 0 More...
 
Vector2 Offset
 the offset to consider for the player's position - usually 0,0 More...
 
bool AutoAdaptOffsetBasedOnPlayerHeight = true
 if this is true, this component will try to automatically adapt its offset based on the player's dimensions More...
 
bool CacheWorldCoordinatesEveryFrame = false
 if this is true, the platform's coordinates will be recomputed every frame, only turn this on if your platform moves. Ideally you'll want to keep this off and manually call CacheColliderWorldCoordinates() every time your platform moves More...
 
bool Inverted = false
 if this is false, the platform will turn itself off when the player is below it, and on otherwise. If Inverted is set to true, then the platform will turn itself off when the player is above, and on when it's below More...
 

Protected Member Functions

virtual void Awake ()
 On Awake we initialize our platform More...
 
virtual void LateUpdate ()
 On LateUpdate we turn our collider on or off More...
 
virtual void HandleColliderBasedOnPlayerPosition ()
 Turns the collider on if the player is above it, off otherwise More...
 
virtual bool PlayerIsAbove ()
 Returns true if the player is above the platform, false otherwise More...
 

Protected Attributes

EdgeCollider2D _edgeCollider2D
 
Vector2 _edgeA
 
Vector2 _edgeB
 
Transform _playerTransform
 
virtual float PlayerPositionX => _playerTransform.position.x + Offset.x
 The x position of the player More...
 
virtual float PlayerPositionY => _playerTransform.position.y + Offset.y
 The y position of the player More...
 

Detailed Description

Add this component to a one way platform (a platform with an edge collider, on the OneWayPlatforms layer) and it will automatically turn its collider on or off based on the player position, letting you easily move it around, and will also let the player collide with it laterally, like a mid height one way platform would, but regardless of its placement or rotation. It's slightly more costly than a regular, static one, but will offer more options too

Member Function Documentation

◆ Awake()

virtual void MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.Awake ( )
protectedvirtual

On Awake we initialize our platform

◆ CacheColliderWorldCoordinates()

virtual void MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.CacheColliderWorldCoordinates ( )
virtual

Stores the positions of the platform's edges

◆ GrabTargetPlayer()

virtual void MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.GrabTargetPlayer ( )
virtual

Stores the target player character

◆ HandleColliderBasedOnPlayerPosition()

virtual void MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.HandleColliderBasedOnPlayerPosition ( )
protectedvirtual

Turns the collider on if the player is above it, off otherwise

◆ Initialization()

virtual void MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.Initialization ( )
virtual

Stores the collider and computes its points' world coordinates

◆ LateUpdate()

virtual void MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.LateUpdate ( )
protectedvirtual

On LateUpdate we turn our collider on or off

◆ PlayerIsAbove()

virtual bool MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.PlayerIsAbove ( )
protectedvirtual

Returns true if the player is above the platform, false otherwise

Returns

Member Data Documentation

◆ _edgeA

Vector2 MoreMountains.CorgiEngine.AnyHeightOneWayPlatform._edgeA
protected

◆ _edgeB

Vector2 MoreMountains.CorgiEngine.AnyHeightOneWayPlatform._edgeB
protected

◆ _edgeCollider2D

EdgeCollider2D MoreMountains.CorgiEngine.AnyHeightOneWayPlatform._edgeCollider2D
protected

◆ _playerTransform

Transform MoreMountains.CorgiEngine.AnyHeightOneWayPlatform._playerTransform
protected

◆ AutoAdaptOffsetBasedOnPlayerHeight

bool MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.AutoAdaptOffsetBasedOnPlayerHeight = true

if this is true, this component will try to automatically adapt its offset based on the player's dimensions

◆ CacheWorldCoordinatesEveryFrame

bool MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.CacheWorldCoordinatesEveryFrame = false

if this is true, the platform's coordinates will be recomputed every frame, only turn this on if your platform moves. Ideally you'll want to keep this off and manually call CacheColliderWorldCoordinates() every time your platform moves

◆ Inverted

bool MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.Inverted = false

if this is false, the platform will turn itself off when the player is below it, and on otherwise. If Inverted is set to true, then the platform will turn itself off when the player is above, and on when it's below

◆ Offset

Vector2 MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.Offset

the offset to consider for the player's position - usually 0,0

◆ PlayerID

int MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.PlayerID = 0

the ID of the target Player to consider for this platform - usually 0

◆ PlayerPositionX

virtual float MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.PlayerPositionX => _playerTransform.position.x + Offset.x
protected

The x position of the player

◆ PlayerPositionY

virtual float MoreMountains.CorgiEngine.AnyHeightOneWayPlatform.PlayerPositionY => _playerTransform.position.y + Offset.y
protected

The y position of the player


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