[Help] isTimeToSpawn doesnt slow down my spawn rate at all!

So, it doesnt matter what value i add into the Seen Every Seconds in inspector. The spawn rate isn’t affected at all. I couldn’t be more lost if you dumped me in the Amazon jungle. I’ve played around with the figures, and nothing happens. In fact, in a bizar twist of events, if I add a large value like 1000000 then nothing at all happens except some odd error to do with my Core Game panel.

Any help please? Pretty please!

bool isTimeToSpawn (GameObject attackerGameObject){
	// first get the attacker prefab
	Attacker attacker = attackerGameObject.GetComponent<Attacker>();

	float meanSpawnDelay = attacker.seenEverySeconds;
	float spawnsPerSecond = 1 / meanSpawnDelay;

	if (Time.deltaTime > meanSpawnDelay) {
		Debug.Log ("Spawn rate capped by frame rate");
	} 

	float threshold = spawnsPerSecond * Time.deltaTime / 5;

	if (Random.value < threshold) {
		return true;
	} else {
		return false;
	}
	return true;
}

I must be tired… The solution, if anybody is interested, is NOT to add the attacker script TWICE. Slap me with a wet fish.

Privacy & Terms