/// <summary> /// Allows for the character to move in a swimming moment. /// </summary> /// <param name="speed"></param> private void Swim(float speed) { // TODO: Handle controller grounded while in water but not submerged if (_input.x == 0 && _input.y == 0) { _moveDir += Physics.gravity * _underWaterGravityMultiplier * Time.fixedDeltaTime; } else if (transform.position.y < _underWater.GetWaterLevel()) { var camRotation = _camera.transform.rotation.eulerAngles.x; var theta = camRotation <= 90 ? camRotation : camRotation - 360; var yMove = theta / 90 * -1; yMove *= _input.y; _moveDir.y = (transform.up * yMove).y * speed; } }