Delayed Collision Detection on Instantly Overlapping Objects. Why?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Is there a science to when collision detection is... detected?

    Say you have an object that, when reaching a certain animation or end of animation, it creates a second invisible detector object that flashes instantly and then destroys itself maybe a frame or two after. When objects that are considered enemies touch this detector, they'll be destroyed. Making this work is not a problem.

    But sometimes, the timing is off. Objects that are enemies being touched at the detector object's creation are destroyed... but often times not in that instant they're colliding or overlapping. It's a frame off, or sometimes even two or three. Is this a known problem with a lot of lines of code or large separations in code? Not sure how to fix or workaround this so that it occurs at the very instant the detector object is create (which would have it already overlapping an enemy object)

  • I've had huge problems in this sense during last weeks.
    I fear there could be some issue on overlapping detection when framerate is "highly stressed".

    But I have no crystal-clear data report on this,
    I only joined these observations:

    - overlapping refused to work after a certain number of objects were on screen (heavily processed: foreach-looped, shader applied, scaled)
    - in these situations, a simple test as "A overlapping B ---> destroy C" didn't trigger
    - I could revert overlapping to a working status by creating less objects on screen
    - in very-stressed-but-not-as-much-to-completely-broke situations, overlapping detection failed on "scaled" objects, but kept working on non-scaled
    - changing to a different method lead to working solutions even on such stressed situations

    a selection of my Fusion examples can be found Please login to see this link.

  • Anyway, re-reading your question, this may be unrelated XD

    For first, if you didn't already,
    I would make sure your collision detection code is placed after your detector-creation code,
    and that there's anything that could conflict inbetween these two checks being performed.

    If you can post an .mfa, maybe we could see if there's something that can be tweaked a little in event succession..

    a selection of my Fusion examples can be found Please login to see this link.

  • After a bit of tweaking, I got it down to a one frame delay. I went and looked over things again and realized that some code was out of order because of the way ForEach loops work, which has now given me an answer to something else I suspected! (Whether or not ForEach loops and fast loops trigger before everything else).

    What I'm not sure of now is if it's possible for there to be zero frames in between collision detection. Example, Object A creates Object B on top of Object C, which destroys Object C, all in one frame sequence.

    Or would it be the fact that there are a lot of alterable values and directional changes and the like being associated with those lines that are making the processing issue complicated?

  • On second thought, I didn't figure things out but found out, or recreated, the problem. I specifically put in things similar to how I have my code in a larger project, checking for Health alterable values and subtracting it, and upon having none, setting the object up to be destroyed.

    This works fine in normal circumstances, but not if the object is being automatically created, possibly during events that don't call for immediate activation ("user clicks with left mouse button" versus "when object is playing x frame.")

    In the frame labeled Clicking, you'll see the Enemy object being destroyed the instant the Detector appears.
    In the frame labeled Self Spawning, however, you'll see the Enemy object linger around for an additional frame when overlapping the Detector before it is destroyed.

    No idea why this happens.

    Please login to see this attachment.

  • I think this is due to the fact that "green" events are called instantly, before anything else,
    so if you created the detector on a non-green event,
    its collision event would be called only on subsequent frame refresh

    i.e.,
    with "green" events:
    Please login to see this attachment.

    Or, with your original example,
    if (more reasonably) you change the condition to "object A overlapping object B" (a non-green event),
    you'll instead have instant destruction on the same frame aswell, because event timing would be the same.

    a selection of my Fusion examples can be found Please login to see this link.

  • The example you posted, with ForEach loops, seems to work... intermittently. Again, not sure why, but "most" of the time, it destroys the instant there is overlap. And then there's a small percentage chance that it's a frame later.

    Switching it to Overlapping seems to work every time though! The only problem I have with that is that if I use Overlapping, it will then trigger multiple times; it will trigger at every frame. And I would like it to only happen once while also avoiding "only one action when event loops" as that tends to lock functionality if I needed to check for multiple instances.

  • Then you could limit the overlapping triggering with a flag

    i.e.
    A overlapping B
    + B flag 0 is off
    >>> set B flag 0 on
    >>> do stuff

    so this won't trigger for the same B again

    (but since once triggered it destroys the object, there shouldn't be many chances of multiple triggering?
    maybe on your real project you do different things X))

    a selection of my Fusion examples can be found Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!