- Home /
Question by
gamecogk · Jun 26, 2012 at 06:17 PM ·
instantiateprefab
Prefab Instantiation
I have created a prefab cPrefab. I have declared a public GameObject gamePrefab in the script.
To make it visible, I dragged the prefab over to the gamePrefab displayed under the script section displayed in the inspector.
When I try to Instantiate, I get the error "the name "cPrefab" does not exist in the current context.
How do I make the prefab accessible so I can Instatiate it?
Comment
Answer by Loius · Jun 26, 2012 at 06:27 PM
public GameObject ob; public Vector3 position; ... GameObject.Instantiate(ob,position); ...
You use variable names in scripts, not object names. Sounds like you're trying to Instantiate(cPrefab) when your script has nothing called 'cPrefab'.
Your answer