Problem when picking family member for deletion

Get help using Construct 2

Post » Mon Dec 09, 2013 3:55 pm

Hi! I have two groups. One to create baubles, one to despawn them after a while. When they despawn the "Missed" counter increases by 1 and it seems to work fine except for the very first spawned family member. When the first one appears the variable for "Missed" is instantly incremented by 1 but the first spawned bauble does not disappear.

I tried to add a global variable as workaround which allows the deletion only after the first one was created but this did not fix or change anything. Does anyone know how to fix this?

Here is the code:
Bl4ckSh33p2013-12-09 15:57:09
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Mon Dec 09, 2013 4:07 pm

You've taken an interesting approach at having timers on multiple objects. I can't offer any help, but I can offer how I would do it myself.

ONLY have the instance variable "LifeTime", which gets set to a random number still when it is created, (int(random(1,6))
And then have an event, that constantly DECREASES the LifeTime variable of the baubles by "dt" (which will make it go down by 1 every second). You may or may not need a "ForEach Baubles" event here, probably not though!
And then have another separate event, that "Compares instance variable" of the baubles, checking if it's =<0, then "play Sheep sound", destroy, ect.

I hope this helps somehow!
B
51
S
20
G
10
Posts: 571
Reputation: 9,819

Post » Mon Dec 09, 2013 4:52 pm

Thanks! I will try this tomorrow.
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Tue Dec 10, 2013 10:56 am

Hi. I changed it how you suggested but the same happens.
When the first bauble is spawned the "Missed" counter is increased by 1 and the bauble is not deleted.
After a few seconds it is deleted and the counter shows 2, but it should be 1.

Bl4ckSh33p2013-12-10 10:57:09
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Tue Dec 10, 2013 11:15 am

Place the "trigger once" conditions in their respective subs and add the actions there.

else the condition checks get done only once ;)lennaert2013-12-10 11:17:20
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Tue Dec 10, 2013 11:27 am


Like this, or did you mean something else?
(Still having the same problem)Bl4ckSh33p2013-12-10 11:27:33
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Tue Dec 10, 2013 11:37 am

Sorry, I had overlooked some differences between the first spawn and despawn


condition 1: pick all baubbles
condition 2: compare variable

This made some difference for me when wanting to select actions from multi picks

Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Tue Dec 10, 2013 12:13 pm

"Compare variable" does only have global vars listed, I tried "compare two values" but now it counts upwards very fast (with and without trigger once) and no baubles appear. :/

B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Fri Dec 13, 2013 2:48 pm

Hi! I'm still trying to fix this and hope I can try a few other things this weekend.

Or does anyone else have an idea how to fix this? Any help would be very much appreciated.
B
54
S
16
G
6
Posts: 719
Reputation: 9,207

Post » Fri Dec 13, 2013 4:28 pm

wouldn't on bubble destroyed add one to counter work?

Or you could use
for each bubble
system compare two values: bubbles.lifetime < 0
- bubble destroy
- add 1 to missedbaubles
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, Shenkai the ssj and 22 guests