- Home /
Question by
eliasunitydev · Apr 14, 2020 at 12:03 PM ·
gameobjectinstantiateprefab
How to instantiate prefab,Instantiating prefab is not wokring in this script
I am trying to create instances from a script. I have a prefab in "Resources/Units"
A script is setup for a sprite and I want to "spawn" multiple objects in a loop like a projectile. I want them to be like that prefab I have in the folder but it is not showing up. It did work if i did setup the gameobject in code without prefab, but i want to use prefab and wonder how to make it work.
-----vars private GameObject myPreFab;
-----start myPreFab = Resources.Load("Units/gren") as GameObject;
Instantiate(myPreFab, gameObject.transform);
This is supposed to create an instance "at the main unit" but it's not showing up.
Comment