Instantiating prefabs?

Hi

Im having trouble getting a prefab cube to instantiate…

I keep getting the error:

NullReferenceException: The prefab you want to instantiate is null.
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at /Users/joe/iphone-clean/Runtime/Export/Generated/BaseClass.cs:63)

  • end paste

Users/joe ??

Im following the scripting manual - and I properly attached the prefab model to a variable assignment in the script field.

Is Users/joe some placeholder for the error codes? or is Unity actually looking for data in Users/joe on my system?

Any help would be appreciated - cheers.

:slight_smile:

Tj

ok

I got it.

I had attached the script BEFORE i assigned the default value.

So the script that assigned the prefab variable was unassigned…

but i kept attaching the object to the variable in the PROJECT window…not in the hierarchy.

So - now Im starting to see its easy to be confused between Project window changes and Hierarchy changes…if your script is not wired properly before being instanced on the hierarchy - your later changes to it on the Project window are not changed in the live version…doh - ok now i understand.

Tj

I was working this too, your tip was great - thanks

Prefabs are a bit confusing at first, but incredibly powerful after you figure it out :slight_smile:

I think probably Joe == Joachim Ante, one of the programming gods at UT. The exception is referencing a line number and filename from the Unity Engine code.