User Tag List

Results 1 to 10 of 10

Thread: Delayed Collision Detection on Instantly Overlapping Objects. Why?

  1. #1
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delayed Collision Detection on Instantly Overlapping Objects. Why?

    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)

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    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

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Anyway, re-reading your question, this may be unrelated

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

  4. #4
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  5. #5
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Re: Delayed Collision Detection on Instantly Overlapping Objects. Why?

    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.

    InstantCollisionTest.mfa

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    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:
    InstantCollisionTest-1.mfa

    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.

  7. #7
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    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 )

  9. #9
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Victory! It worked! And, yes, that definitely isn't my real project. I'm not going to make a "Aqua Diamond Destroyer" game. :p

    Thanks for your help!

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    That's a shame, I would have enjoyed an "Aqua Diamond Destroyer" game

    good luck with your project

Similar Threads

  1. Replies: 5
    Last Post: 9th December 2014, 10:49 PM
  2. Collision Detection on moving objects
    By bad_rick in forum Fusion 2.5
    Replies: 4
    Last Post: 10th July 2014, 02:48 PM
  3. Collision Detection with Backdrops Overlapping Each Other
    By stevenart1988 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 11th July 2013, 01:39 PM
  4. Question: Collision detection for overlapping objects
    By ardo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th February 2012, 06:08 PM
  5. Bug with overlapping collision detection?
    By mobichan in forum SWF/Flash Export Module Version 2.0
    Replies: 5
    Last Post: 2nd April 2010, 11:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •