The enemy (prefabs) have a scripts. The scripts need the Game object called bullet(prefabs).The enemy only will produced by Instantiate. I can’t put the bullet(prefabs) to the scripts of enemy (prefabs).How can I solve this?
Good day.
You need to store your prefab in a folder called Resources. Lets say you have stored there a prefab called “bullet”.
Lets instantiate it.
GameObject InstatiatedObject = Instantiate (Resources.Load ("bullet") as GameObject, position, rotation);
And now you can access that bullet like any other object (example):
InstatiatedObject.GetComponent<BulletScript>().damage = 5;
And thats all you need!