Error with instantiate after build

Hi, I was trying to add a ‘fireball’ attack to my wave game, and built the game after i got it working in the editor. When I ran the file I got a wierd error in my log file:

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Object.Internal_InstantiateSingle_Injected(UnityEngine.Object,UnityEngine.Vector3&,UnityEngine.Quaternion&)
  at UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) <0x1f249e69bb0 + 0x00062> in <3a69dc1755714a688e272fb29550dc99>:0 
  at UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) [0x00025] in C:\buildslave\unity\build\Runtime\Export\Scripting\UnityEngineObject.bindings.cs:202 
  at UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) [0x00009] in C:\buildslave\unity\build\Runtime\Export\Scripting\UnityEngineObject.bindings.cs:276 
  at Player.Update () [0x00207] in C:\Users\d.o22\Desktop\CS30 PROJECT DO\Assets\Scripts\Player Scripts\Player.cs:95 
 
(Filename: C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs Line: 202)

Here is line 95 which it says has a problem:

GameObject FireballGO = Instantiate(FB, vfbsp, Quaternion.identity);

It works completely fine in the editor, but i get these errors only in build. I searched online and found about 2 others with a similar issue, but there were no answers to their problem. If you need more info to help let me know and ill try to provide. Thanks.

Hello @d-ostapa,

Could you tell me a bit more about the GameObject FB and the Vector3 vfbsp (I’m assuming that’s a Vector3-- not sure of overloads for Instantiate() off the top of my head, could be a Transform that it’s converting to Vector3)?

  1. Are they referencing objects from the Inspector?
  2. Or are they assigned earlier in code?
  3. What platform are you building? (Guessing Windows, just want to be sure)

-Jason