Unity "ArgumentExeption: The object you want to instantiate is null." need help.
So I'm making a game, its a turret defense game (I'm following Brackeys tutorial on youtube) and I'm trying to make it so when I click on these nodes, it builds a turret to shoot the enemies. the problem is, when I get done with the script, unity says "ArgumentException: The Object you want to instantiate is null." I have no idea what this means or how I can fix it, any suggestions would be welcome. Thanks in advance.
Please, provide the code throwing the error.
In your code, you surely have something like :
var myObject = Instantiate( prefab, position, rotation ) ;
$$anonymous$$ake sure that the prefab is not null. $$anonymous$$aybe you have forgotten to drag & drop the prefab in the inspector ?
this is the code I have
turret = (GameObject)Instantiate(turretToBuild, transform.position, transform.rotation);
I do have the prefab referenced in the inspector, I have checked that several times. enter code here
If turretToBuild is correctly assigned in the inspector, then maybe there's another gameobject with that script on it. If you search the Hierarchy for the name of your script (case sensitive), every appearance of it should pop up. Do this when you received the error and see which bastard has it's variable not set.
Your answer
Follow this Question
Related Questions
rigidbody2D's velocity not working 1 Answer
Help with code for picking up objects 1 Answer
My bolt isn't respawning in game Its driving me crazy i have been at it for 2 days !! 1 Answer
Unexpected 'Void' expecting 'class' 0 Answers
ArgumentOutOfRange: Argument is out of range Parameter name: index 0 Answers