NullReferenceException: Object reference not set to an instance of an object
Player.PlayerController.ApplyMovement () (at Assets/Scripts/Player/PlayerController.cs:124)
Player.PlayerController.FixedUpdate () (at Assets/Scripts/Player/PlayerController.cs:102)
This is the mistake ı am getting How can ı fix this problem
using System;
using ProInput.Scripts;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Player {
public class PlayerController : MonoBehaviour {
Animator animator;
public bool Run;
public bool RunningJump;
public AudioClip _soundd; // this lets you drag in an audio file in the inspector
public AudioSource audioo;
void Awake()
{
audioo = audioo; //oadds an AudioSource to the game object this script is attached to
audioo.playOnAwake = false;
audioo.clip = _soundd;
audioo.Stop();
Run = false;
animator = GetComponent<Animator>();
GetComponent<Rigidbody>(); //Set the speed of the GameObject
}
[Header("Movement")]
public float movementSpeed;
public float Accelaration;
public float airMovementSpeed;
public float maxSpeed;
[Header("Friction")]
public float friction;
public float airFriction;
[Header("Rotation")]
public float rotationSensitivity;
public float rotationBounds;
[Header("Gravity")]
public float extraGravity;
[Header("Ground Detection")]
public LayerMask whatIsGround;
public float checkYOffset;
public float checkRadius;
public float groundTimer;
[Header("Jumping")]
public float jumpForce;
public float jumpCooldown;
[Header("Data")]
public Camera playerCamera;
public Transform playerCameraHolder;
public Rigidbody playerRigidBody;
private InputObject forwardsInput;
private InputObject backwardsInput;
private InputObject leftInput;
private InputObject rightInput;
private InputObject _jumpInput;
private InputObject _runInput;
private float _xRotation;
private float _yRotation;
private float _grounded;
private bool _realGrounded;
private float _jumpCooldown;
private void Start() {
forwardsInput = new InputObject("Forwards", Key.W);
backwardsInput = new InputObject("Backwards", Key.S);
_runInput = new InputObject("run", Key.LeftShift );
leftInput = new InputObject("Left", Key.A);
rightInput = new InputObject("Right", Key.D);
_jumpInput = new InputObject("Jump", Key.Space);
}
private void FixedUpdate() {
GroundCheck();
ApplyMovement();
}
private void Update() {
Rotation();
ApplyGravity();
ApplyFriction();
RollJumping();
}
private void ApplyMovement() {
if (_realGrounded==false)
{
var axis = new Vector2(
(leftInput.IsPressed ? -1 : 0) + (rightInput.IsPressed ? 1 : 0),
(backwardsInput.IsPressed ? 0 : 0) + (forwardsInput.IsPressed ? 0 :0)
).normalized;
var speed = _realGrounded ? movementSpeed : airMovementSpeed;
var vertical = axis.y * speed * Time.fixedDeltaTime * transform.forward;
var horizontal = axis.x * speed * Time.fixedDeltaTime * transform.right;
if (CanApplyForce(vertical, axis))
playerRigidBody.velocity += vertical;
if (CanApplyForce(horizontal, axis))
playerRigidBody.velocity += horizontal;
}
}