How do I make objects spawn/drop only one object a time?

Get help using Construct 2

Post » Fri Jun 06, 2014 11:37 pm

Have the condition about the collusion with the object, then have an additional condition with it where Triggers Once While True.

Edit: Added another attachment that shows it on a sub-event after the triggered collision detection.
You do not have the required permissions to view the files attached to this post.
B
10
S
2
G
1
Posts: 44
Reputation: 817

Post » Sat Jun 07, 2014 12:04 am

There are two type of event in C2, you can try 'Add Event' in the c2 event editor and noticed there are ones with green little arrow in the bottom left corner. These ones with green little arrow are of trigger once type, it will only be executed once if it happens (of course it will be executed again if it happens again in the future, but only once per occassion).

As for On collision, it is of the trigger once type, it will only be executed once, that is why you can't add trigger once while true with it.

PS: The on overlap is the continuous trigger equivalent for on collision
B
36
S
6
G
2
Posts: 190
Reputation: 4,223

Post » Sat Jun 07, 2014 12:10 am

@daehawk It doesn't require to add "trigger once" because an event you implemented "On Collision with" it's a trigger, every conditions have green arrow icons are triggers.

Otherwise other conditions don't come green arrow, are updates in every tick.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Sat Jun 07, 2014 12:29 am

Joannesalfa wrote:@daehawk It doesn't require to add "trigger once" because an event you implemented "On Collision with" it's a trigger, every conditions have green arrow icons are triggers.

Otherwise other conditions don't come green arrow, are updates in every tick.


@Joannesalfa The collusion itself triggers once but the sub-event that is dropping the books for him is triggering multiple times. That's why he needs the Trigger once on the one that spawns the books since he only wants one book to spawn but it is sometimes spawning 2-3 instead.
B
10
S
2
G
1
Posts: 44
Reputation: 817

Post » Sat Jun 07, 2014 12:32 am

You could also give the ghost an instance variable that is a cooldown time. When the character collides with the ghost, set the cooldown value and have it count down to 0. Only allow books to drop when the value is 0.

Another way to do it would be to set a the current time as the variable and only spawn a book when the current time value is greater then the desired cooldown + the time value.

Conversely, you could set the next time a book is allowed to spawn on the ghost and only spawn the book when the current time is greater than the time value set.

Attached is a capx with all 3 examples. Pick the 1 you like the best.
You do not have the required permissions to view the files attached to this post.
B
40
S
12
G
11
Posts: 331
Reputation: 7,752

Post » Sat Jun 07, 2014 2:08 am

Seems the "Trigger once while true" cannot be used as a co-condition, you do have to create a sub-event.
Simple example:
>character on collision with ghost -> {Actions to be done very beginning when collide with ghost}
>Trigger once -> {Your book spawning actions here}
>Blank condition -> {Other actions after spawning the book here}
B
13
S
2
Posts: 11
Reputation: 786

Post » Sat Jun 07, 2014 7:22 am

daehawk wrote:
Joannesalfa wrote:@daehawk It doesn't require to add "trigger once" because an event you implemented "On Collision with" it's a trigger, every conditions have green arrow icons are triggers.

Otherwise other conditions don't come green arrow, are updates in every tick.


@Joannesalfa The collusion itself triggers once but the sub-event that is dropping the books for him is triggering multiple times. That's why he needs the Trigger once on the one that spawns the books since he only wants one book to spawn but it is sometimes spawning 2-3 instead.


@daehawk So you censored your implementation in screenshot, I don't know why you would censor it.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Fri Jun 13, 2014 6:12 pm

Hello all. Yeah, this is what what my code looks like right now, but it still drops 2 or 3 books sometimes... basically, the "trigger once" sub-event doesn't seem to be working. What the heck is going on here lol?

Image
B
36
S
9
G
1
Posts: 629
Reputation: 3,956

Post » Fri Jun 13, 2014 7:41 pm

Never mind, thanks a lot @FragFather. The first option (the green Cooldown) works best for me, it's exactly what I was looking for... a cool-down period! For all the help, Thanks again everyone.
B
36
S
9
G
1
Posts: 629
Reputation: 3,956

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot], zenox98 and 8 guests