Monster Respawn 'Fix'
3
💡
1
😯
1Maybe I setup my monster spawners wrong, or this was an intended feature, but I consider it a bug, as it appears that currently the Cooldown Timer has no effect on the first respawn (or future spawns if the monsters take a while to kill). I.e., if you allow unlimited respawns, the countdown of the cooldown for respawn happens in the background, and it attempts to respawn a new monster only if there is room, it will fail, but the second there is room, it will spawn, so you end up with effectively a 0 second respawn. If you are able to kill the respawn faster than the cooldown, then it won’t happen instantly, but it’s not ideal. This minor change uses existing logic, but changes it so it never counts down unless there is room to spawn it, so the cooldown is actually a cooldown.
In AMonsterSpawner.cs Change Update() the (m_valid check)
if (m_valid)
{
bool belowSimultaneousCap = m_spawnedMonsters.Count < m_maxSimulatenousMonsterCount;
bool belowGlobalCap = CanSpawn();
if (belowSimultaneousCap && belowGlobalCap)
{
m_spawnTimer -= Time.deltaTime;
if (m_spawnTimer <= 0.0f)
{
m_spawnTimer = m_spawnCooldown;
TrySpawn();
}
}
else
{
m_spawnTimer = m_spawnCooldown;
}
}

💬 Comments (0)
Be the first to comment! Join our Discord to share your thoughts.
Want to continue the conversation?