private IEnumerator OnWallEnter() { // Make Player Stick to the wall characterPhysics.currentGravityState = GravityState.OnWall; characterPhysics.ResetGravity(); StartCoroutine(FallFromWall()); // After 0.2f Reseting Impact so the player won't slide up the wall yield return(new WaitForSeconds(0.2f)); characterPhysics.ResetImpact(); }
private IEnumerator CalculateDash(Vector3 inputDirection) { // Calculate the angle of dash based on the Character Rotation Angle float targetAngle = Mathf.Atan2(inputDirection.x, inputDirection.z) * Mathf.Rad2Deg; Vector3 dashDirection = Quaternion.Euler(0f, transform.eulerAngles.y + targetAngle, 0f) * Vector3.forward; // Coroutine for Dash Cooldown StartCoroutine(ResetDash()); // If Character is Falling also Pushes the Character Down if (characterPhysics.currentGravityState == GravityState.Falling) { dashDirection += Vector3.down; } characterPhysics.AddForce(dashDirection, dashForce); // Reseting Impact After dash is done yield return(new WaitForSeconds(dashDuration)); characterPhysics.ResetImpact(); }