Trigger once ruins enemy deaths,disabling it ruins variable

Get help using Construct 2

Post » Thu Apr 27, 2017 10:59 am

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.

Image

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.
B
5
S
1
Posts: 13
Reputation: 351

Post » Thu Apr 27, 2017 2:18 pm

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.
B
6
S
1
Posts: 14
Reputation: 378

Post » Thu Apr 27, 2017 3:33 pm

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.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Mon May 08, 2017 1:22 pm

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.
B
5
S
1
Posts: 13
Reputation: 351

Post » Mon May 08, 2017 6:52 pm

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
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461


Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 6 guests