Camera resets when character hits the ground

Blockquote

using Godot;
using System;

public partial class newt : CharacterBody3D
{
public const float Speed = 5.0f;
public const float JumpVelocity = 4.5f;
public float mouseSensitivity = 0.05f;

// Get the gravity from the project settings to be synced with RigidBody nodes.
public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();

private Node3D camerabase;

private Node3D camera;


private float yaw;
private float pitch;

public override void _Ready()
{
    camerabase = GetNode<Node3D>("CameraBase");
    camera = GetNode<Camera3D>("CameraBase/camera");
    Input.MouseMode = Input.MouseModeEnum.Captured;
}

public override void _PhysicsProcess(double delta)
{
    Vector3 velocity = Velocity;

    // Add the gravity.
    if (!IsOnFloor())
        velocity.Y -= gravity * (float)delta;

    // Handle Jump.
    if (Input.IsActionJustPressed("jump") && IsOnFloor())
        velocity.Y = JumpVelocity;

    // Get the input direction and handle the movement/deceleration.
    Vector3 direction = new Vector3();
    if (Input.IsActionPressed("move_forward"))
    {
        direction -= camerabase.GlobalTransform.Basis.Z;
    }
    if (Input.IsActionPressed("move_backward"))
    {
        direction += camerabase.GlobalTransform.Basis.Z;
    }
    if (Input.IsActionPressed("move_left"))
    {
        direction -= camerabase.GlobalTransform.Basis.X;
    }
    if (Input.IsActionPressed("move_right"))
    {
        direction += camerabase.GlobalTransform.Basis.X;
    }

    direction = direction.Normalized();

    if (direction != Vector3.Zero)
    {
        velocity.X = direction.X * Speed;
        velocity.Z = direction.Z * Speed;
    }
    else
    {
        velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed * (float)delta);
        velocity.Z = Mathf.MoveToward(Velocity.Z, 0, Speed * (float)delta);
    }

    Velocity = velocity;
    MoveAndSlide();
}

public override void _Input(InputEvent @event)
{
    if (@event is InputEventMouseMotion mouseMotionEvent)
    {
        float sensitivityAdjustedX = mouseMotionEvent.Relative.X * mouseSensitivity;
        float sensitivityAdjustedY = mouseMotionEvent.Relative.Y * mouseSensitivity;

        yaw -= sensitivityAdjustedX;
        pitch = Mathf.Clamp(pitch - sensitivityAdjustedY, -90, 90);

        // Apply rotations
        camerabase.RotationDegrees = new Vector3(0, yaw, 0);
        camera.RotationDegrees = new Vector3(pitch, 0, 0);
    }
}

}

When I first run the game the camera position is fine (I’m looking for a 3rd person POV), and I have my character start above the ground. However, when it hits the ground, the camera position changes and I can’t figure out why. It has to do with pitch and yaw as I wasn’t having the problem until I added it in. Does anyone know what’s wrong? I can upload the entire project if needed. Thanks!