How do I create Ticking Bombs That Activate On Player Collision/Overlap?

  • Hello guys, I'm having a bit of trouble with making bombs.

    The idea is similar to the Crash Bandicoot games, where if the player touches a bomb, a countdown begins and when it reaches 0 it explodes instantly (You never see 0 on the bomb).

    This has been a real pain to work out, fixing one issue seems to create another!

    One implementation for example would not stop the countdown during pausing the game...

    I remade the whole system to be simpler using the Every X Second condition to control the countdown, but now the bombs run their countdowns one at a time even if more than one of them are activated!

    Example:

    What should happen: Player touches bomb 1 and then almost immediately bomb 2, both their respective countdowns begin the instant the Player overlaps/collides with them.

    What happens: Player touches bomb 1 and then almost immediately bomb 2. Bomb 1 Begins countdown instantly, but gets stuck when Bomb 2 gets activated. Bomb 2 starts countdown but doesn't change animation.

    Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a timer behaviour. You assign it to the bomb and say when bomb is activated, trigger once, start timer. construct.net/en/make-games/manuals/construct-3/behavior-reference/timer

  • There is a timer behaviour. You assign it to the bomb and say when bomb is activated, trigger once, start timer. construct.net/en/make-games/manuals/construct-3/behavior-reference/timer

    Hey, I just managed to get it right using Every tick and dt.

    It seems to work right so far, gotta test more.

    By the way, is there a way to get the the time elapsed since the timer began? I had tried using the Timer before but couldn't find a way to get that...

  • Yes it's object.timer.currenttime("timer name")

  • Yes it's object.timer.currenttime("timer name")

    Ah, I see.

    Do you think using timers is less resource heavy than Every Tick conditions?

    This is what I currently have:

    CPU is around 30% and I get solid 60 fps for now at least.

    (Haven't made any levels with many bombs)

  • I don't think it matters too much although it's more difficult to track what's going on with 'time' than if you assigned a timer behaviour to the bomb. You are basically saying on it becoming activated calculate some time from that point, well you can do this with a timer behaviour and track it on each bomb. I can't think of a more obvious use for a timer behaviour than a bomb :D Also I should note the timer is affected by timescale so when you are trying to pause the game it will stop the timer and resolve that issue for you.

  • I don't think it matters too much although it's more difficult to track what's going on with 'time' than if you assigned a timer behaviour to the bomb. You are basically saying on it becoming activated calculate some time from that point, well you can do this with a timer behaviour and track it on each bomb. I can't think of a more obvious use for a timer behaviour than a bomb :D Also I should note the timer is affected by timescale so when you are trying to pause the game it will stop the timer and resolve that issue for you.

    Ah yes, the Pause issue happens again with the current method, though I managed to fix it with a an inverted Boolean check for "Game_Paused" (It stops subtracting dt when the Game is Paused)

    My only issue at the moment is it seems that the alarm sound plays one more time just before it explodes but it should play only 3 times, but it shouldn't be too hard to fix.

    I see what you mean, timer seems to be a more proper way to implement this.

    Well, I'll try coding that too and keep which one seems more stable.

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