Trigger once ruins enemy deaths,disabling it ruins variable

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hi, I faced two problems during the development of my big project. Basically both of them solve a problem of the other, but then add in their own flaws.

    I recently made changes to this event handling enemy deaths, because I tried to make a system, where every time I kill one enemy, 1 point is added to a special meter variable. This caused the first problem: on each enemy death, instead of adding just one, the special meter variable added an enormous amount of numbers, much more than it shoud have. I figured out that it was probably because the event was of the kind which has to be told to trigger once.

    I added this trigger once condition you see in my code and it solved the counting confusion. However it created a new issue.

    Now whenever, I faced a bigger amount of enemies (around 10), at some point they stopped being destroyed. I took a look at the debug and according to it, the enemies did take damage, but it had went under zero and added minus values, without destroying the enemies.

    As you can see in this pic, when I toggle disabled that "trigger once" it solves one problem and adds another and when I enable it, the same happens the other way.

    I dont know which way I should fix and stick into, but I hope youll be able to help me with either one.

  • I am new to this forum, but i guess, you could make the object (maybe the bullet) touch another object and use this as the trigger.

    Spawn the explosion, add the point and then destroy the object (bullet).

    The explosion object can handle the "Die" animation and destroy itself.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Rather than relying on Trigger-once, which only works under certain circumstances, manage the logic yourself. Get rid of the first Wait, so that the bullet & collisions are disabled immediately, then replace Trigger-once with "Follownemy_hp.Collisions enabled". Since you've explicitly disabled collisions, you know that condition won't be met the next time round.

    I also avoid Wait, so use a timer on the Follownemy_hp and set it to expire in 0.5s. Then do the destroy and Add in the "On timer" event.

    The problem with Trigger-once and Wait is they aren't object specific. By making all of you logic object specific, you have 100% control over the behavior/logic of each object.

  • Thank you both for help, blackhornets reply solved it! While fixing it as you told, I finally got the way how timers work. I had difficulties understanding them and avoided them but not anymore. Ill also keep in mind what you said about Trigger once and Wait, that was also new.

  • You could also set a trigger that destroys and adds a point when the animation "Die" finishes. (Just do a for each Enemy every tick)

    That way you get rid of the wait, and the timer

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