Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

When spawning bullet prefab with Instantiate, the bullet works, but still getting UnassignedReferenceException

$
0
0
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.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>