How do I break the mass collision effect?

0 favourites
  • 13 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • I struggle with this for a while now.

    I have several sprites in the "enemies" family. Enemies are walking from top of the screen to the bottom. At the bottom of the screen I have an invisible sprite which is simply a - let's call it - finishing line. So when the enemy touch the line, player loose and the score screen appears.

    Now the problem is that if more than one enemy touch the line in the same time "On collision" events run multiple times.

    I've tried even something like that

    On collision ->
         some actions
         disable "on collision" group[/code:3bkoshp2]
    
    And it is fine for a while, because indeed it runs only once even when many enemies touch it, but then when I back to the play screen I have to enable this group again and then it instantly runs again. Like it have in the buffer.
    
    Any ideas how to run On collision efect only once even when there are multiple enemies touching it?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could also use the Is Overlapping condition for this, since it is not an event it's not triggered as such, so there can't be any ''backlog'' that has to be processed, it only checks at that moment in time.

    I use it to detect a sword hitting an enemy like this:

  • On collision ->

    Pick instance 0 ->

    some actions

  • You could make something like a trigger.

    Create a local variable called "trigger" (needs to be static and needs to be reset to 0 at start of level)

    For the collision event to run the trigger needs to be 0.

    And if the collision event triggers set the trigger to 1.

    So it should just run ones.

  • That's actually a fairly elegant solution, That way he won't need to disable collision on the object, but still retain his current workflow.

  • I used this because construct has no real or function. (at least not as i understand)

    So if you have an event with X subevents and you just want one of them to trigger and then skipping the other

    ones thats what i did.

    Or to make on/off switches with global variables (global variables cant be booleons so cant use toggle)

  • Thanks for the replies Guys.

    You could also use the Is Overlapping condition (...)

    Is Overlapping is not an observer condition, so with the number of my enemies that would be probably way to much CPU consuming...

    On collision ->

    Pick instance 0 ->

    some actions

    If I'm not mistaken this will run multiple time anyway, just the effect of actions will go to the picked instance.

    You could make something like a trigger.

    Create a local variable called "trigger" (needs to be static and needs to be reset to 0 at start of level)

    For the collision event to run the trigger needs to be 0.

    And if the collision event triggers set the trigger to 1.

    So it should just run ones.

    Well yes I was thinking about adding a variable to check this, but somehow I don't find it the elegant solution, so I thought there must be some simplier way.

    Anyway I will give a shot to all of the propositions. Thanks!

  • Thanks for the replies Guys.

    > You could also use the Is Overlapping condition (...)

    >

    Is Overlapping is not an observer condition, so with the number of my enemies that would be probably way to much CPU consuming...

    -SNIP-

    Fair enough, I had not considered that to be honest. My current fidget projects are all PC based prototypes.

  • Ok then the hardcore way.

    on collision--->destroy the finishing line!

    finishing line on destroy---> get score and end level

    It can only be destroyed ones so it can just trigger ones.

    The levels ends anyway so you dont need it anymore.

  • Ok then the hardcore way.

    on collision--->destroy the finishing line!

    The levels ends anyway so you dont need it anymore.

    It won't work. On collision condision trigger SOL is already in the memory so there is no second check if the line is there or not. That's why it's kinda tricky

  • Maybe but it doesent matter.

    Thats why you trigger the scoring by the on destroy event.

  • It won't work. On collision condition trigger SOL is already in the memory so there is no second check if the line is there or not. That's why it's kinda tricky

    That's where the Pick instance 0 helps.

  • Allright I've fixed it. So it turned out that there was something else in the project causing unwanted behaviour... but it doesn't matter cause at least I've played around with the On collision condition.

    So the results.

    I really hoped that blackhornet solution would work cause it looks really decent, but unfortunately as I predicted in my previous post it run multiple times anyway just the events under this condition impact the instance 0 (multiple times).

    dsminor trick with destroying finishing line worked (I didn't get what you mean at first .

    I haven't try Is Overlapping as Gumball suggested, cause this would be a performance killer in my case for sure... I have hundreads of enemies on the screen so I really have to think about the performance. I am even combining On collision with Every X second to save some CPU ;D (BTW: it works )

    I don't think there is any decent solution for executing event under On collision condition only once, but surely there are many workarounds we can do.

    Again thanks for your help guyz!... I can finally go a step further with finishing this game

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)