im new to unity and my movement script keeps giving me this error:
NullReferenceException: Object reference not set to an instance of an object
here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
private float horizontal;
private float speed = 8f;
private Rigidbody2D rb;
void FixedUpdate()
{
horizontal = Input.GetAxisRaw("Horizontal");
rb.velocity = new Vector2(horizontal * speed, 0);
}
}