// ClimbingLedgeState = Animator.StringToHash("Climbing.ClimbingLedge"); protected void ClimbingLedge(float elapsedTime) { // Make sure we actually have a ledge to climb up if (_ledge == null) { Debug.LogWarning("Player Character's Ledge Not Found!"); MecanimAnimator.SetBool(MecanimHashes.Fall, true); return; } // The motion for climbing ledges is somewhat complicated... if ((Direction.x > 0 && transform.position.x > _ledge.transform.position.x + _ledge.GetComponent <Collider>().bounds.extents.x) || (Direction.x < 0 && transform.position.x < _ledge.transform.position.x - _ledge.GetComponent <Collider>().bounds.extents.x) || CurrentState.normalizedTime > 0.9) { MecanimAnimator.SetBool(MecanimHashes.ClimbLedge, false); VerticalSpeed = GroundVerticalSpeed; } else if (transform.position.y > _ledge.transform.position.y + _ledge.GetComponent <Collider>().bounds.extents.y + Height / 2) { VerticalSpeed = 0; } else { if (_ledge.DoesFaceZAxis()) { HorizontalSpeed = 0.0f; VerticalSpeed = Settings.LedgeClimbingSpeed; } else if (_ledge.DoesFaceXAxis()) { HorizontalSpeed = Direction.x * Settings.LedgeClimbingSpeed; VerticalSpeed = Settings.LedgeClimbingSpeed; } } SetMecanimAnimatorHorizontalSpeedFloat(); MecanimAnimator.SetFloat(MecanimHashes.VerticalSpeed, VerticalSpeed); MecanimAnimator.SetBool(MecanimHashes.Fall, false); }
protected void ClimbingLedge(float elapsedTime) { if (_ledge == null) { Debug.LogWarning("Olympus's Ledge Not Found!"); MecanimAnimator.SetBool(MecanimHashes.Fall, true); return; } MecanimAnimator.SetBool(MecanimHashes.Fall, false); if ((Direction.x > 0 && transform.position.x > _ledge.transform.position.x + _ledge.GetComponent <Collider>().bounds.extents.x) || (Direction.x < 0 && transform.position.x < _ledge.transform.position.x - _ledge.GetComponent <Collider>().bounds.extents.x) || CurrentState.normalizedTime > 0.9) { MecanimAnimator.SetBool(MecanimHashes.ClimbLedge, false); VerticalSpeed = GroundVerticalSpeed; } else if (transform.position.y > _ledge.transform.position.y + _ledge.GetComponent <Collider>().bounds.extents.y + Height / 2) { VerticalSpeed = 0; } else { if (_ledge.DoesFaceZAxis()) { HorizontalSpeed = 0.0f; VerticalSpeed = Settings.LedgeClimbingSpeed; } else if (_ledge.DoesFaceXAxis()) { HorizontalSpeed = Direction.x * Settings.LedgeClimbingSpeed; VerticalSpeed = Settings.LedgeClimbingSpeed; } } }