I am using Instantiate to spawn a bullet prefab like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullets : MonoBehaviour
{
public Transform firePoint;
public GameObject bulletPrefab;
void Update()
{
if (Input.GetButtonDown("Fire1")) {
Shoot();
}
}
void Shoot() {
Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
}
}
It is working exactly how I want it to, but I keep getting the error
UnassignedReferenceException: The variable firePoint of Bullets has not been assigned.
You probably need to assign the firePoint variable of the Bullets script in the inspector.
Should I just ignore this, or will it affect something I may want to do down the line, and if so, how could I fix it, and if not, how could I stop this error from showing up? Help is much appreciated.
↧