I recently started experimenting with unity- in particular, the FPS microgame, and wanted to make a new weapon or object in said game. I duplicated the script, took all the normal steps, but I’m not sure why I keep getting the message:
“ArgumentException: The Object you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:374)
UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:197)
UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:276)
WeaponController.HandleShoot () (at Assets/FPS/Prefabs/Weapons/WeaponController.cs:343)
WeaponController.TryShoot () (at Assets/FPS/Prefabs/Weapons/WeaponController.cs:294)
WeaponController.HandleShootInputs (System.Boolean inputDown, System.Boolean inputHeld, System.Boolean inputUp) (at Assets/FPS/Prefabs/Weapons/WeaponController.cs:261)
PlayerWeaponsManager.Update () (at Assets/FPS/Scripts/PlayerWeaponsManager.cs:116)”
I’m pretty sure I referenced my prefab (a model I made in blender) as the root for the script. Can somebody tell me how to fix this? Sorry if this seems like a stupid question.
What does the inspector look like for your script?
I wasn’t sure if i was supposed to use the physical .blend file for my root, but I did (it’s called starwarsgun)