Null Reference Exception

Hi I am new to unity game development and I am trying to run locomotion movement on my character. I found a script online fixed all the animations and controllers but i get this message

NullReferenceException: Object reference not set to an instance of an object
Character.Update () (at Assets/Locomotion/Scripts/Character.cs:73)

The full script is as follows

using UnityEngine;
using UnityEngine.InputSystem;

public class Character : MonoBehaviour

{
[Header(“Controls”)]
public float playerSpeed = 5.0f;
public float crouchSpeed = 2.0f;
public float sprintSpeed = 7.0f;
public float jumpHeight = 0.8f;
public float gravityMultiplier = 2;
public float rotationSpeed = 5f;
public float crouchColliderHeight = 1.35f;

[Header(“Animation Smoothing”)]
[Range(0, 1)]
public float speedDampTime = 0.1f;
[Range(0, 1)]
public float velocityDampTime = 0.9f;
[Range(0, 1)]
public float rotationDampTime = 0.2f;
[Range(0, 1)]
public float airControl = 0.5f;

public StateMachine movementSM;
public StandingState standing;
public JumpingState jumping;
public CrouchingState crouching;
public LandingState landing;
public SprintState sprinting;
public SprintJumpState sprintjumping;

[HideInInspector]
public float gravityValue = -9.81f;
[HideInInspector]
public float normalColliderHeight;
[HideInInspector]
public CharacterController controller;
[HideInInspector]
public PlayerInput playerInput;
[HideInInspector]
public Transform cameraTransform;
[HideInInspector]
public Animator animator;
[HideInInspector]
public Vector3 playerVelocity;

private void Start()
{
controller = GetComponent();
animator = GetComponent();
playerInput = GetComponent();
cameraTransform = Camera.main.transform;

movementSM = new StateMachine();
standing = new StandingState(this, movementSM);
jumping = new JumpingState(this, movementSM);
crouching = new CrouchingState(this, movementSM);
landing = new LandingState(this, movementSM);
sprinting = new SprintState(this, movementSM);
sprintjumping = new SprintJumpState(this, movementSM);

movementSM.Initialize(standing);

normalColliderHeight = controller.height;
gravityValue *= gravityMultiplier;
}

private void Update()
{
movementSM.currentState.HandleInput();

movementSM.currentState.LogicUpdate();
}

private void FixedUpdate()
{
movementSM.currentState.PhysicsUpdate();
}
}

It occurs twice both on line 73 and line 80 which are

movementSM.currentState.HandleInput();
movementSM.currentState.PhysicsUpdate();

respectively

I dont really know why it does it does anyone have an idea? Or would anyone be willing to offer a fix for this issue

  1. Use the code subforum for this
  2. Use code tags!!

If the error is in those lines, that means that MovementSM (less likely because of the initialization you did) or currentState (more likely) is not set. Debug log them to see

A null reference just means a field or variable that was supposed to have a value has nothing in it. I see the script is trying to use three components (GetComponent<>()). Check that all three of them are on the GameObject that the script is attached to.