Instantiate question

Hey,

I have a script that is instantiating other prefabs, however each prefabs needs a different spawn rate, i’d like to store that spawn rate value in each prefabs but i’m not sure how i can access that from the spawner script, i’m sure there is a simple solution to that.

Any suggestions?

I wanted to throw in that the spawn rate could also be defined in your spawner, side by side with each prefab you want to instantiate. Like this:

public class Spawner : MonoBehaviour {

	[System.Serializable]
	struct Prefabs{
		public GameObject prefab;
		public float spawnRate;
	}

	[SerializeField] Prefabs[] prefabs;

}

you then have as many combinations of GameObject and its spawn rate, without the need of a common base class for the prefabs, which, IMHO, are not responsible for that kind of information.