public static bool CheckLadderKind(PlayerEntity player, out LadderLocation location, bool considerDirection = false) { location = LadderLocation.Null; var playerTransform = player.RootGo().transform; var pos = playerTransform.position; Vector3 capsuleBottom, capsuleUp; float capsuleRadius; PlayerEntityUtility.GetCapsule(player, pos, out capsuleBottom, out capsuleUp, out capsuleRadius); //DebugDraw.DebugWireSphere(capsuleBottom, Color.red, capsuleRadius); var length = Physics.OverlapSphereNonAlloc(capsuleBottom, capsuleRadius, colliders, UnityLayers.ClimbLadderLayerMask); if (length == 0) { return(false); } location = CheckLadderLocation(colliders, length, playerTransform, considerDirection); return(location != LadderLocation.Null); }
private void Reset() { _isUsingLadder = false; _triggerEnterOnce = false; _triggerExitOnce = false; if (null != _thirdPersonAnimator) { _thirdPersonAnimator.applyRootMotion = false; } _toLadderLocation = LadderLocation.Null; _ladderKind = LadderKind.Null; }
private void TestExitLadderImpl(LadderLocation ladderLocation) { _toLadderLocation = ladderLocation; if (!_isUsingLadder || _triggerEnterOnce || _triggerExitOnce) { return; } if (LadderLocation.Bottom == ladderLocation && _ladderSpeed < -0.05f || (LadderLocation.Top == ladderLocation && _ladderSpeed > 0.05f)) { _ladderKind = LadderKind.Exit; TriggerExitLadder(); } }
private void TestEnterLadderImpl(LadderLocation location) { _toLadderLocation = location; if (_isUsingLadder || _triggerEnterOnce || _triggerExitOnce) { return; } if (_ladderSpeed > 0.05f) { if (LadderLocation.Bottom == location || LadderLocation.Top == location) { _ladderKind = LadderKind.Enter; TriggerEnterLadder(); } else if (LadderLocation.Middle == location) { TriggerMiddleEnterLadder(); } } }
public void TestEnterLadder(LadderLocation location) { TestEnterLadderImpl(location); }
public void Update(LadderLocation ladderLocation) { TestExitLadderImpl(ladderLocation); }