C# Класс UnityPlatformer.PlatformerCollider2D

Handle collisions with the world
Наследование: RaycastController
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
enableSlopes bool
maxClimbAngle float
maxDescendAngle float
minTranslation float
onLanding System.Action
onLeaveGround System.Action
onLeftWall System.Action
onRightWall System.Action
onTop System.Action
wallAngle float

Открытые методы

Метод Описание
ClimbSlope ( Vector3 &velocity ) : void

Modify velocity to smooth climb current slope

ConsolidateCollisions ( ) : void

After all work, notify changes

DescendSlope ( Vector3 &velocity ) : void

Modify velocity to smooth descend current slope

DiagonalCollisions ( Vector3 &velocity ) : void

Unused. This may be redundant still experimental to fix some edge cases...

DisableLeaveGround ( ) : void

same as: 'leavingGround=false' to be used with: UpdateManager.SetTimeout

DisableSlopes ( float resetDelay = 0.5f ) : void

Disable slopes, so no more ClimbSlope/DescendSlope This is important, because while on slope, velocity.y will be modified If you need your velocity to remain, you must disable slopes.\n NOTE use it for jumping over a slope

EnableLeaveGround ( float resetDelay = 0.5f ) : void

leavingGround = true during resetDelay time

EnableSlopes ( ) : void

same as: 'enableSlopes=true' to be used with: UpdateManager.SetTimeout

FallThroughPlatform ( float resetDelay = 0.5f ) : void

fallingThroughPlatform = true during resetDelay time

GetDownSlopeDir ( ) : Vector3

Vector pointing were to descend / slip

HorizontalCollisions ( RaycastHit2D &ray, Vector3 &velocity, int dir, int idx ) : void

Callback for ForeachLeftRay/ForeachRightRay

IsOnGround ( int graceFrames ) : bool

Collider is/was on ground. This is useful to give player some help, no pixel precision jumps :)

Move ( Vector3 velocity, float delta ) : Vector3

Attempt to move the character to current position + velocity. Any colliders in our way will cause velocity to be modified ex: wall -> stop. slope -> modifiy velocity.\n NOTE collisions.velocity has the real velocity applied

OnEnable ( ) : void
ResetFallingThroughPlatform ( ) : void

same as: 'fallingThroughPlatform=false' to be used with: UpdateManager.SetTimeout

Start ( ) : void
UpdateCurrentSlope ( Vector3 velocity ) : void

Launch rays and get the maximum slope found

VerticalCollisions ( RaycastHit2D &ray, Vector3 &velocity, int dir, int idx ) : void

Callback for ForeachHeadRay/ForeachFeetRay

Описание методов

ClimbSlope() публичный Метод

Modify velocity to smooth climb current slope
public ClimbSlope ( Vector3 &velocity ) : void
velocity Vector3 Amount to be moved
Результат void

ConsolidateCollisions() публичный Метод

After all work, notify changes
public ConsolidateCollisions ( ) : void
Результат void

DescendSlope() публичный Метод

Modify velocity to smooth descend current slope
public DescendSlope ( Vector3 &velocity ) : void
velocity Vector3 Amount to be moved
Результат void

DiagonalCollisions() публичный Метод

Unused. This may be redundant still experimental to fix some edge cases...
public DiagonalCollisions ( Vector3 &velocity ) : void
velocity Vector3 Amount to be moved
Результат void

DisableLeaveGround() публичный Метод

same as: 'leavingGround=false' to be used with: UpdateManager.SetTimeout
public DisableLeaveGround ( ) : void
Результат void

DisableSlopes() публичный Метод

Disable slopes, so no more ClimbSlope/DescendSlope This is important, because while on slope, velocity.y will be modified If you need your velocity to remain, you must disable slopes.\n NOTE use it for jumping over a slope
public DisableSlopes ( float resetDelay = 0.5f ) : void
resetDelay float 0 means no reset
Результат void

EnableLeaveGround() публичный Метод

leavingGround = true during resetDelay time
public EnableLeaveGround ( float resetDelay = 0.5f ) : void
resetDelay float 0 means no reset
Результат void

EnableSlopes() публичный Метод

same as: 'enableSlopes=true' to be used with: UpdateManager.SetTimeout
public EnableSlopes ( ) : void
Результат void

FallThroughPlatform() публичный Метод

fallingThroughPlatform = true during resetDelay time
public FallThroughPlatform ( float resetDelay = 0.5f ) : void
resetDelay float 0 means no reset
Результат void

GetDownSlopeDir() публичный Метод

Vector pointing were to descend / slip
public GetDownSlopeDir ( ) : Vector3
Результат Vector3

HorizontalCollisions() публичный Метод

Callback for ForeachLeftRay/ForeachRightRay
public HorizontalCollisions ( RaycastHit2D &ray, Vector3 &velocity, int dir, int idx ) : void
ray UnityEngine.RaycastHit2D result of Raycast horizontally
velocity Vector3 Amount to be moved
dir int Direction
idx int ray index
Результат void

IsOnGround() публичный Метод

Collider is/was on ground. This is useful to give player some help, no pixel precision jumps :)
public IsOnGround ( int graceFrames ) : bool
graceFrames int 0 means current frame
Результат bool

Move() публичный Метод

Attempt to move the character to current position + velocity. Any colliders in our way will cause velocity to be modified ex: wall -> stop. slope -> modifiy velocity.\n NOTE collisions.velocity has the real velocity applied
public Move ( Vector3 velocity, float delta ) : Vector3
velocity Vector3 Amount to be moved (velocity * delta)
delta float Time since last update
Результат Vector3

OnEnable() публичный Метод

public OnEnable ( ) : void
Результат void

ResetFallingThroughPlatform() публичный Метод

same as: 'fallingThroughPlatform=false' to be used with: UpdateManager.SetTimeout
public ResetFallingThroughPlatform ( ) : void
Результат void

Start() публичный Метод

public Start ( ) : void
Результат void

UpdateCurrentSlope() публичный Метод

Launch rays and get the maximum slope found
public UpdateCurrentSlope ( Vector3 velocity ) : void
velocity Vector3 Amount to be moved
Результат void

VerticalCollisions() публичный Метод

Callback for ForeachHeadRay/ForeachFeetRay
public VerticalCollisions ( RaycastHit2D &ray, Vector3 &velocity, int dir, int idx ) : void
ray UnityEngine.RaycastHit2D result of Raycast vertically
velocity Vector3 Amount to be moved
dir int Direction
idx int ray index
Результат void

Описание свойств

enableSlopes публичное свойство

Enable slopes Slopes modify Y position of the collider, even when velocity is really X only, to give a smooth movement
public bool enableSlopes
Результат bool

maxClimbAngle публичное свойство

Maximum angle the collider can walk-up
public float maxClimbAngle
Результат float

maxDescendAngle публичное свойство

Maximum angle the collider can walk-down
public float maxDescendAngle
Результат float

minTranslation публичное свойство

Prevent unwanted micro changes in orientation/falling. Makes the Collider more stable to changes.\n This is not a magnitude, handle X/Y separately
public float minTranslation
Результат float

onLanding публичное свойство

Collider hit the ground
public Action,System onLanding
Результат System.Action

onLeaveGround публичное свойство

Collider leave ground
public Action,System onLeaveGround
Результат System.Action

onLeftWall публичное свойство

Collider hit a wall on left side
public Action,System onLeftWall
Результат System.Action

onRightWall публичное свойство

Collider hit a wall on right side
public Action,System onRightWall
Результат System.Action

onTop публичное свойство

Collider hit something with the 'Head'
public Action,System onTop
Результат System.Action

wallAngle публичное свойство

Greater than wallAngle will be considered a Wall, not a slope
public float wallAngle
Результат float