How do I use trigger once and for each in the same event?

Get help using Construct 2

Post » Tue Dec 29, 2015 5:10 pm

In the capx below, I tried to have the game spawn the green ship, then the blue ship, based on their "Distance" from the player ship. I created a family for the enemy ships, and made a family instance variable called "DistanceX." Every second I subtract one from each ships DistanceX. The ships start out with different DistanceX's, so it will take one longer to reach zero. I wanted it to spawn each ship when it's DistanceX = zero. But they're different instances of the same object, so i used the "For each" loop, and I don't want it to spawn a million times so I used "Trigger once while true". No matter what configuration I use, it either spawns both at the same time, or spawns them in a random order endlessly. if any of you know what is wrong, or how I can acheive the desired effect, I would love it. Thank you so much, in advance.

Link to capx: https://www.dropbox.com/s/wl6cj3urjhk96 ... .capx?dl=0
Last edited by Cam112549 on Tue Dec 29, 2015 9:32 pm, edited 1 time in total.
B
8
S
2
Posts: 39
Reputation: 604

Post » Tue Dec 29, 2015 8:31 pm

You dont need for each here..

Just check the distanceX variable on the familymember and trigger once..
Events work by filtering specific instances that meet some conditions. The actions then run for those instances only.
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

Post » Tue Dec 29, 2015 9:29 pm

Here's the new capx, doing what you said: https://www.dropbox.com/s/wwzckg0gohio3 ... .capx?dl=0
It's only spawning one, in a random order intsead of both, Green -->Blue. Is there any way I can have it spawn the green, then blue, without having to code it manually for each? Thank you, sorry for being a bother.
B
8
S
2
Posts: 39
Reputation: 604

Post » Wed Dec 30, 2015 6:26 am

Have you used a spawn variable ? such as For every X distance Add one to spawn and run a command something like if spawn > 0 then create object and then decrease one from spawn. or you can even create something like for every X distance use variable Green ship spawn and one for Blue ship spawn.

So that the spawn variable act as a trigger and the Spawn > 0 act a trigger for you ?
B
51
S
24
G
6
Posts: 391
Reputation: 7,820


Return to How do I....?

Who is online

Users browsing this forum: imhotep22 and 9 guests