I have a prefab that is an empty Gameobject and a Gameobject that is acting as an enemy. I’m trying to get the enemy Gameobject to spawn at the empty Gameobject. I want to be able to move the empty Gameobject anywhere and the enemy Gameobject would still spawn there without me having to change the code. Can I even do this with instantiate or do I need to use so etching else? If I can. Use instantiate what do I put in the vector3 spot?
Well, you don’t typically Instantiate inside of a prefab, but rather Instantiate a new instance of the prefab it’s self.
It’s very easy.
var MyGameObject ;
MyGameObject = Instantiate ( objectBeingStantiated, transform.position, transform.rotation ) ;
You can then move it around just as you move everything else in the game .
Or Perhaps, are you trying to copy the contents of prefab1 to prefab2 ? ( which is basically the exact same )
The game object position is given by transform.position. If the empty object instantiates the prefab at its position (and with the same rotation), use this:
Instantiate(prefab, transform.position, transform.rotation);