0 Favourites

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

  • Hello all, I was wondering... How do I make it so that spawns drop only one object a time? For example, when my main character collides with a ghost, the ghost will drop/spawn a spellbook. The problem is that when the character collides with the ghost, it will sometimes spawn two or three spellbooks instead of just one:( How do I make it so that the ghost will spawn only one spellbook at a time when the character collides with it?

    Thanks,

    guannstar (Fnord)

  • Trigger once while true

  • Thanks, can you show me what the code path look like? How do you "Trigger once while true"?

  • Add this condition to the event where the main character collides with the ghost....

    character on collision with ghost

    trigger once action > ghost spawn book

    Trigger once while true

    Turn an ordinary event (which is tested every tick) in to a trigger. For example, if an event plays a sound when lives equals 0, normally this event runs every tick. This plays about 60 sounds a second and would sound pretty bad. Adding Trigger once while true after the other conditions makes the event run just once when it first becomes true. This makes the previous example only play a sound once the first time your lives reaches 0. It must be the last condition in an event.

  • Thanks a lot, I'll try that and get back to you:)

  • Hey, I'm trying to add a condition to ">character on collision with ghost", but there's no ">trigger once action" option available. What should I do?

  • Do you know what I'm saying? Do I have to make it a sub-event or something? Why can't I just add a condition?

  • When I try to add a condition, it says, "Due to the restrictions on triggers, some conditions could not be pasted here.":(

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Bump, please guys, I really need some help:(

  • Bump.

  • 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.

  • 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

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
234 61,230
DARKSETH's avatar
DARKSETH
Unread hot topic
167 14,497
DMT2005's avatar
DMT2005
Unread sticky
1 Favourites
C2 Games made with CocoonIO
136 89,824
minhcuong's avatar
minhcuong