NullReferenceException: Object reference not set to an instance of an object
Player.FixedUpdate () (at Assets/Script/Player.cs:17)
my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
private Rigidbody2D rb;
[SerializeField] private float movingSpeed = 5f;
private void Awake() {
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate() {
Vector2 inputVector = GameInput.Instance.GetMovementVector();
inputVector = inputVector.normalized;
rb.MovePosition(rb.position + inputVector * (movingSpeed * Time.fixedDeltaTime));
}
and
using UnityEngine;
public class GameInput : MonoBehaviour {
public static GameInput Instance { get; private set; }
private PlayerInputActions playerInputActions;
private void Awake() {
Instance = this;
playerInputActions = new PlayerInputActions();
playerInputActions.Enable();
}
public Vector2 GetMovementVector() {
Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>();
return inputVector;
}
}
pls help me
type or paste code here