I am struggling with sprinting and jumping components within my Script, Can anyone help out?

So I’m struggling with my bool of isSprinting and the animation connection between the two. I’ve been furiously attempting everything videos have taught me and nothing is working. Can anyone help out? Here is the entire script

using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class PlayerAction : MonoBehaviour
{
    public float walkSpeed = 2f;
    public float runSpeed = 4f;
    public float rotationSpeed = 0.15f;
    public float jumpForce = 5f;
    
    
    private bool isGrounded;
    private bool jumpRequested;
    private Rigidbody rb;
    private Vector3 moveInput;
    private Animator animator;
    private Player_controls controls;
    private static readonly int State = Animator.StringToHash("State");
    private static readonly int jump = Animator.StringToHash("Jump");
    private static readonly int Run = Animator.StringToHash("Run");
     public bool isSprinting;

    private enum PlayerState
    {
        Idle = 0,
        Walk = 1,
        Run = 2
    }

    private void Awake()
    {
        rb = GetComponent<Rigidbody>();
        animator = GetComponent<Animator>();
        controls = new Player_controls();

        controls.Player.SprintS.performed += x => SprintPressed();
        controls.Player.SprintF.performed += x => SprintReleased();
    }

    private void SprintPressed()
    {
        isSprinting = true;
    }

    private void SprintReleased()
    {
        isSprinting = false;
    }

    // Start is called before the first frame update
    void Start()
    {

    }
    
    // Update is called once per frame
    void Update()
    {
        // Ground checking is done on Update to be preformed per frame
        // Cast a ray downward to check if close to ground
        Vector3 rayOrgin = transform.position + Vector3.up * 0.1f;
        float rayDistance = 2f;

        if (Physics.Raycast(transform.position, Vector3.down, out var hit, rayDistance))
        {
            if (hit.collider.CompareTag("Ground"))
            {
                isGrounded = true;
            }
        }
        
        //check id jump is triggerd.
        // if jump is not trigger, request for jump to be preformed. 
        if (controls.Player.Jump.triggered && isGrounded)
        {
            jumpRequested = true;
        }
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        // read input device value
        Vector2 input = controls.Player.Move.ReadValue<Vector2>();
        moveInput = new Vector3(input.x, 0f, input.y);

        // move the player using Rigid body
        if (isSprinting == true)
        {
            rb.MovePosition(rb.position + moveInput * (runSpeed * Time.deltaTime));
            SetAnimationState(PlayerState.Run);

            if (moveInput.magnitude >= 0.1f)
            {
                // change player rotation to face the movement direction.
                Quaternion newRotation = Quaternion.LookRotation(moveInput, Vector3.up);
                rb.rotation = Quaternion.Slerp(rb.rotation, newRotation, rotationSpeed);

                // set the animation State to Running.
                SetAnimationState(PlayerState.Run);










            }
            else
            {
                SetAnimationState(PlayerState.Idle);
            }


        }


        else
        {
            rb.MovePosition(rb.position + moveInput * (walkSpeed * Time.deltaTime));



            // if there is meaningful movement, rotate player in the direction
            // of the movement and set animation to walk
            if (moveInput.magnitude >= 0.1f)
            {
                // change player rotation to face the movement direction.
                Quaternion newRotation = Quaternion.LookRotation(moveInput, Vector3.up);
                rb.rotation = Quaternion.Slerp(rb.rotation, newRotation, rotationSpeed);

                // set the animation State to walking.





                SetAnimationState(PlayerState.Walk);





            }
            else
            {
                SetAnimationState(PlayerState.Idle);
            }

            // Preform jump
            if (jumpRequested && isGrounded)
            {
                rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
                animator.SetTrigger(jump);
                isGrounded = false;
                jumpRequested = false;
            }
        }
    }

   private void SetAnimationState(PlayerState animState)
        {
            animator.SetInteger(State, (int)animState);
        }


    private void OnEnable()
        {
            controls.Enable();
        }
    private void OnDisable()
        {
            controls.Disable();
        }
}

Hello KurtTheJunkie, I’m KurtTheDekker.

Whenever you have issues like this:

Staring at code is rarely the solution. You have to find what the code is actually doing.

That means it is time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

When working with tutorials, us this two-step process:

Two steps to tutorials and / or example code:

  1. do them perfectly, to the letter (zero typos, including punctuation and capitalization)
  2. stop and understand each step to understand what is going on.

If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.

Imphenzia: How Did I Learn To Make Games: