Topic was automatically imported from the old Question2Answer platform.
Asked By
Montasir Raihan
Hello everyone, I’m making a top down 2D survival game where the player needs to survive by killing zombies and creeps. I made a timer named “ZomTimer” which spawns zombies and creeps when the time runs out. But after a certain amount of kills, the timer stops functioning and doesn’t spawn zombies and creeps. I checked my codes over and over again to catch the error but I found nothing. What kind of problem is this? And how do I solve it? Please help me to fix this problem. Here’s the code to help you understand the problem:
I don’t see what in this code is responsible for restarting this timer over and over ? Is any other node affecting the timer or is it just set on constant loop ? Or does it just spawn creeps once and than breaks ? You said it stop working after some amount of kills, but is there any connection between zombie deaths and timer reset ?
Umm that’s a lot of question.
But yes, after the player reaches 75 kills the game spawns a boss named Super Creep and I wanted to pause the timer until the player kills it. The timer will come back to normal when the Super Creep dies. Just Like this:
if kill % 75 == 0 and kill != 0:
$Path2D/PathFollow2D.offest = randi()
$SuperCreep.activate()
$SuperCreep.position = $Path2D/PathFollow2D.position
$ZomTimer.paused = true
And when the boss dies:
$SuperCreep.deactivate()
$ZomTimer.paused = false
But somehow, I couldn’t pause the timer when the boss appears so I followed this method:
if kill % 75 == 0 and kill != 0:
$Path2D/PathFollow2D.offest = randi()
$SuperCreep.activate()
$SuperCreep.position = $Path2D/PathFollow2D.position
$ZomTimer.stop()
And when the boss dies
$SuperCreep.deactivate()
$ZomTimer.stop()
Montasir Raihan | 2021-02-28 15:09
Wait, so Your problem is Timer stopping forever after killing certain amount of creeps. Is it this 75 amount ?
Because You coded to stop the Timer when You kill 75 creeps, and then You stop it again after killing the boss… So is there anything coded to restart it ?
Inces | 2021-02-28 15:50
Sorry, I wrote the code wrong here, After the boss dies the timer starts. It was just a writing mistake.
Montasir Raihan | 2021-02-28 17:52
But the kill amount is not fixed. Sometimes the timer stops forever after 1 or 2 kills or sometimes 142 kills. It’s not fixed.
Montasir Raihan | 2021-02-28 17:54
I mean the kill amount changes randomly.
Montasir Raihan | 2021-02-28 18:01
Well there must be something influencing timers, maybe undirectly. What happens when regular zombie dies ? Can You debug how is the timer stopped ? In what position ? At worst You could print its time-left in process()