How do I build around a timer

  • I have a top-down shooter where enemies are spawned based on time. I've created a timer that counts time since the start of the layout - since game time isn't reliable after you've died or moved levels, etc.

    The problem I'm getting is I tell the system to spawn an enemy when the timer = 20. If I set the timer to tick up every one second, then it will spawn like 50 enemies because of the length of time that the scenario is true. If I set the timer to count up by tenths or hundredths of a second, then the system won't even register 20.00 seconds and nothing will spawn. I've messed around with half seconds, quarter seconds, etc. and there doesn't seem to be a sweet spot. I either get a stream of enemies or no spawn.

    The odd thing is that if I use game time then it's flawless. I say spawn at 20 seconds and it only spawns one sprite. Also, game time doesn't sync up with any of the timers I've made, it will hit 10 seconds when my timer is at like 6.5, even though they're both counting up in seconds. I feel like I have to be doing something stupid. Please help!

  • Use the Timer behaviour. It is a better mechanism for accurate timing.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use the Timer behaviour. It is a better mechanism for accurate timing.

    Thanks for the response - I read it, looked it up, and everything I found were things I had already tried. Not to be a complete n00blet but if you or someone else has a minute would you mind explaining the process in detail? I actually scrapped this project for 3 months but I'd really like to finish it.

    If it's any help / reminder - I can't use system time because you can't control that. With pause menus, boss fights, etc. -- it's not reliable. I've tried making global timers but it's either too specific (e.g. on a 00:00:00 timer) and it doesn't hang on "00:20:00" long enough for the system to spawn a single enemy OR it's too vague (counting up in just seconds and minutes) and the system will spawn a wall of enemies for the time that the timer = "00:20" If there's a built in timer function, I can't find it :/ I won't be offended if you explain it to me like I'm 5yo.

    Many thanks ahead of time (but not too descriptive of time because that would spawn a wall of "thanks"...)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)