GameObject needs to check information on counter

I already have a counter that counts upward after my player collides with a downed enemy. Each enemy is worth “1.” I need help with the counter code so I can instantiate a prefab once it gets to a specific number. Any ideas? Thanks!

Sure, this is pretty simple actually. I’m assuming you’re using C#…

public GameObject ThingToInstantiate;  //This is the thing we're going to spawn.
public int NumberToGet=5; //This is how many downed enemies we need to get.
private bool spawned=false;  //This is used so we dont spawn more than one of the above objects...
private int counter=0;  //This is your counter number that you already have working...

void Update(){
  if(!spawned && counter >= NumberToGet){

And that should be that. Granted thats only psudo-code, and you’ll need to actually give whatever you’re instantiating there a real position, but otherwise that should do it for you I think.

um, if need it to trigger exactly when it hits a number you can do this:

public int triggerCount = 800; //When the coutner reaches this number (set in editor), trigger the event (default 800)

private int _myCounter;
public int myCounter{
		return _myCounter;
		_myCounter = value;
		if(_myCounter == triggerCount){


private void doMyEvent(){
	//put your instantated code here