"Trigger once" and multiple instances

Get help using Construct 2

Post » Sat Aug 03, 2013 12:07 am

Hey all,

I've recently been having some problems when using 'trigger once' when there are multiple instances of an object.

Have a look at This simple capx.

Basically, it's a very simple code that tells the squares to change their opacity when they hit the grey square.

However, you will notice that the very top instance never changes its opacity. If you remove the 'for each', even stranger things happen.

(I know I could just use 'on collision' but this is just for example purposes ;) )

Is this a bug in C2, or just a weird side effect of 'trigger once'?
B
92
S
30
G
24
Posts: 3,191
Reputation: 32,584

Post » Sat Aug 03, 2013 2:05 am

Maybe a bug of the SC2 engine, stuttering/skipping the top part of the code on start, since
I added a simple "wait 1 sec" and it works.


capxCalifornia2013-08-03 02:12:04
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Sat Aug 03, 2013 2:11 am

whoa @sqiddster, even weirder than disabling "for each":
disable the "for each", but leave the "wait 1 sec" enabled.
It works.

bug?
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Mon Aug 05, 2013 3:45 am

I wouldn't say a bug really as all "trigger once" is run once every time the previous event changes from false to true. So within a loop i'm unsure what it should do at least I can't wrap my mind around it.

The is overlapping is only false when none of the objects overlap, so trigger once is working as expected if the for each is removed.

Or perhaps it is a bug. What do you think the expected behavior should be in the case of the example? Or should there be another condition like "trigger once per object"?
B
85
S
27
G
85
Posts: 5,070
Reputation: 57,874

Post » Mon Aug 05, 2013 4:03 am

I think a 'trigger once per object' would be an excellent addition to the game.

Right now I'm creating a board game where both the player and computer spawn units before the game starts. The trickiest part for me was creating computer spawning in a way that happens sequentially instead of spawning all of its units at once. I think a 'trigger once per object' would have made my events a lot simpler.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Mon Aug 05, 2013 4:14 am

@Excal - That's a great idea! Make sure you submit it to @Ashley in the suggestions forum.

@R0J0hound - On that note, I would THINK it ought to still act accordingly for each instance (without the For Each loop). If it works mostly as it should without the Trigger Once, then all Trigger Once should do is work once PER instance if true. It doesn't make sense to stop it altogether for all instances just because ONE instance meets the conditions.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
127
S
21
G
8
Posts: 759
Reputation: 14,327

Post » Mon Aug 05, 2013 4:52 am

Yeah, something like 'trigger once per instance' would be very nice. I guess the best way to do it at the moment would be to have a trigger boolean?
B
92
S
30
G
24
Posts: 3,191
Reputation: 32,584

Post » Mon Aug 05, 2013 5:31 am

Im not so sure a "trigger once for each instance" is such a good idea, as it will probably cause more confusion. After all it is a system condition, so it should either pick all or just the first index just like system compare does.
Then it seems like there would be no point to add a condition to objects since a simple variable will do, or in this case compare opacity.
Image ImageImage
B
164
S
49
G
139
Posts: 7,966
Reputation: 92,398

Post » Mon Aug 05, 2013 5:46 am

Wouldn't trigger once for each instance be same as:

conditions
trigger once
-- for each object
B
24
S
8
G
7
Posts: 756
Reputation: 7,242

Post » Mon Aug 05, 2013 2:04 pm

let's ask the man @Ashley
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Next

Return to How do I....?

Who is online

Users browsing this forum: bikachu, ikazuchi, irwandwiyanto, thatserafimkid and 2 guests