Script Example:
public class Example : MonoBehaviour { public ParticleSystem particles; private GameObject prefab; void Update() { // Finds object with script attached, once it spawns into scene if (FindObjectsOfType<AnotherScript>().Length != 0) { prefab = GameObject.Find("ObjectThatSpawns"); particles.transform.position = prefab.transform.position } }
This code was working flawlessly until it randomly stopped for no reason. I haven’t changed anything about it or anything associated with it. Now I get a NullReferenceException.
I’ve transferred it into multiple different scripts and still gives the error.
NOTE: The NullReference is pointed at the "particles.transform.position = prefab.transform.position"
Anonymous Asked question May 13, 2021
Recent Comments