"Trigger once" not working as expected, please look.

Get help using Construct 2

Post » Sun Feb 08, 2015 5:35 pm

So, I have this logic (check the attached screenshot)

When the "block's" travel distance is >50 then it triggers once to spawn another "block".

Problem is, after it spawns 1 block it doesn't continue to spawn.

What I want is to have the "block" spawn another "block" EVERYTIME the "block" traveled 50.

askc2.png
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 39
Reputation: 507

Post » Sun Feb 08, 2015 5:46 pm

Use a variable (named distance50 here).

foreach bullet :

each tick : bullet.distance50 = bullet.distance
when bullet.distance ≥ 50, bullet spawns block and sets bullet.distance50 to 0
Last edited by Coin-coin le Canapin on Sun Feb 08, 2015 5:48 pm, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sun Feb 08, 2015 5:48 pm

This isn't the right place to use "Trigger once" -- distance traveled won't magically reset after your bullet goes 50 pixels, so the condition is true and remains true, thus trigger once runs exactly once, as designed.

What I'd recommend is to give your block an instance variable, called "spawnCount", perhaps. Then do something like this:
Image
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Sun Feb 08, 2015 5:49 pm

Linkman2004's solution is more elegant than mine by the way :D
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sun Feb 08, 2015 7:00 pm

linkman2004 wrote:This isn't the right place to use "Trigger once" -- distance traveled won't magically reset after your bullet goes 50 pixels, so the condition is true and remains true, thus trigger once runs exactly once, as designed.

What I'd recommend is to give your block an instance variable, called "spawnCount", perhaps. Then do something like this:
Image


Thank you very much, this worked :)
B
7
S
1
Posts: 39
Reputation: 507


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Jackriduk and 30 guests