problem with exploding projectiles
So, let me give you a bit of context since the title can be a bit misleading.
I was following a youtube tutorial of a creator known as Dave. To be more specific, this video:
link: https://www.youtube.com/watch?v=0jGL5_DFIo8
Anyways, I have completed the tutorial and ran the game. That's where something interesting happens. For the first few seconds the game was running perfectly. After those second the projectile (with or without colliding to anything) simply exploded. When I try to shoot again, I receive this error message:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object. UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) (at :0)
UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at :0)
UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at :0)
Gun.Shoot () (at Assets/Scripts/Gun.cs:96)
Gun.myInput () (at Assets/Scripts/Gun.cs:66)
Gun.Update () (at Assets/Scripts/Gun.cs:42)
I can't find the problem when checking the scripts. I even downloaded Dave's scripts to check if the my scripts matches with his, and they do.
I have no idea what to do. Can someone help?
Answer by powerminer3 · Sep 11, 2021 at 09:01 AM
Never mind, I fixed it. Turns out that I forgot to set the bullet into a prefab.
Your answer

Follow this Question
Related Questions
Target lead (aim ahead) problem 1 Answer
m_size < k_reference_bit error 0 Answers
il2cpp/build/il2cpp.exe did not run properly! 5 Answers
compiler error - playmode 0 Answers
Admob Errors 1 Answer