C# 클래스 CharacterController2D, WorldsofREM

상속: MonoBehaviour
파일 보기 프로젝트 열기: jmkmoore/WorldsofREM 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
jumpingThreshold float
platformMask LayerMask
slopeSpeedMultiplier AnimationCurve
triggerMask LayerMask
usePhysicsForMovement bool

공개 메소드들

메소드 설명
OnTriggerEnter2D ( Collider2D col ) : void
OnTriggerExit2D ( Collider2D col ) : void
OnTriggerStay2D ( Collider2D col ) : void
move ( Vector3 deltaMovement ) : void

attempts to move the character to position + deltaMovement. Any colliders in the way will cause the movement to stop when run into.

recalculateDistanceBetweenRays ( ) : void

this should be called anytime you have to modify the BoxCollider2D at runtime. It will recalculate the distance between the rays used for collision detection. It is also used in the skinWidth setter in case it is changed at runtime.

warpToGrounded ( ) : void

moves directly down until grounded

비공개 메소드들

메소드 설명
Awake ( ) : void
DrawRay ( Vector3 start, Vector3 dir, Color color ) : void
handleHorizontalSlope ( Vector3 &deltaMovement, float angle ) : bool

handles adjusting deltaMovement if we are going up a slope.

handleVerticalSlope ( Vector3 &deltaMovement ) : void

checks the center point under the BoxCollider2D for a slope. If it finds one then the deltaMovement is adjusted so that the player stays grounded and the slopeSpeedModifier is taken into account to speed up movement.

moveHorizontally ( Vector3 &deltaMovement ) : void

we have to use a bit of trickery in this one. The rays must be cast from a small distance inside of our collider (skinWidth) to avoid zero distance rays which will get the wrong normal. Because of this small offset we have to increase the ray distance skinWidth then remember to remove skinWidth from deltaMovement before actually moving the player

moveVertically ( Vector3 &deltaMovement ) : void
primeRaycastOrigins ( Vector3 futurePosition, Vector3 deltaMovement ) : void

resets the raycastOrigins to the current extents of the box collider inset by the skinWidth. It is inset to avoid casting a ray from a position directly touching another collider which results in wonky normal data.

메소드 상세

OnTriggerEnter2D() 공개 메소드

public OnTriggerEnter2D ( Collider2D col ) : void
col UnityEngine.Collider2D
리턴 void

OnTriggerExit2D() 공개 메소드

public OnTriggerExit2D ( Collider2D col ) : void
col UnityEngine.Collider2D
리턴 void

OnTriggerStay2D() 공개 메소드

public OnTriggerStay2D ( Collider2D col ) : void
col UnityEngine.Collider2D
리턴 void

move() 공개 메소드

attempts to move the character to position + deltaMovement. Any colliders in the way will cause the movement to stop when run into.
public move ( Vector3 deltaMovement ) : void
deltaMovement Vector3 Delta movement.
리턴 void

recalculateDistanceBetweenRays() 공개 메소드

this should be called anytime you have to modify the BoxCollider2D at runtime. It will recalculate the distance between the rays used for collision detection. It is also used in the skinWidth setter in case it is changed at runtime.
public recalculateDistanceBetweenRays ( ) : void
리턴 void

warpToGrounded() 공개 메소드

moves directly down until grounded
public warpToGrounded ( ) : void
리턴 void

프로퍼티 상세

jumpingThreshold 공개적으로 프로퍼티

the threshold in the change in vertical movement between frames that constitutes jumping
public float jumpingThreshold
리턴 float

platformMask 공개적으로 프로퍼티

mask with all layers that the player should interact with
public LayerMask platformMask
리턴 LayerMask

slopeSpeedMultiplier 공개적으로 프로퍼티

curve for multiplying speed based on slope (negative = down slope and positive = up slope)
public AnimationCurve slopeSpeedMultiplier
리턴 AnimationCurve

triggerMask 공개적으로 프로퍼티

mask with all layers that trigger events should fire when intersected
public LayerMask triggerMask
리턴 LayerMask

usePhysicsForMovement 공개적으로 프로퍼티

toggles if the RigidBody2D methods should be used for movement or if Transform.Translate will be used. All the usual Unity rules for physics based movement apply when true such as getting your input in Update and only calling move in FixedUpdate amonst others.
public bool usePhysicsForMovement
리턴 bool