User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Faster to run always check distance vs always check collision?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Question Faster to run always check distance vs always check collision?

    I have always heard that collision and overlap checks are among the heaviest to make in regards of performance. I am wondering if it would be good to use a distance calculation before a collision check to increase performance, or if that is not a good idea?

    For example I have a level with the player and 5 mines. I could have an event running all the time for checking if player is overlapping the mines. Or I could have an always event where I store a value in the mines for how far they are from the player in X and Y cordinates

    (like Sqr(((X( "Mine" )-X( "Player" )) pow 2)+((Y( "Mine" )-Y( "Player" )) pow 2))

    When they are close enough (the number is low enough) I activate the collision checking. What do you guys think of this?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fanotherpg's Avatar
    Join Date
    Jul 2006
    Location
    High Wycombe, Buckinghamshire, UK
    Posts
    3,665
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would make some improvement yes, if seperated to two events.

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I don't think it would, especially for that few of objects. MMF likely already checks bounding boxes before narrowing down potential collisions, and the overhead of calculating square roots and powers each frame will be much higher than any speed benefit you'd get from cutting out two or three collision checks (although still wouldn't be noticeable).

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    How about if the objects are in the current frame window?

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,305
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Go with normal collision checks - it gives you pixel-perfect collision detection, and for a small number of small objects, it won't cause any slowdown.
    It's only when you're dealing with large objects that collision detection becomes slow (and it does then become very, very slow - even with just a handful of objects).

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fanotherpg's Avatar
    Join Date
    Jul 2006
    Location
    High Wycombe, Buckinghamshire, UK
    Posts
    3,665
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MuddyMole and what about our realtime pixel perfect platformer shadow - only 32 objects in a loop and was causing massive slow-downs, before we changed it to tricks to minimize amount of collision checks to 0.

  7. #7
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    905
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    What were these tricks?

  8. #8
    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator ProUnicode Add-on

    Join Date
    Jun 2011
    Posts
    628
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Outcast View Post

    (like Sqr(((X( "Mine" )-X( "Player" )) pow 2)+((Y( "Mine" )-Y( "Player" )) pow 2))

    When they are close enough (the number is low enough) I activate the collision checking. What do you guys think of this?
    This will work faster if you use Advanced Direction Object.

  9. #9
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    As it's been mentioned... for this amount of objects, it really doesn't matter what you do. You won't see any difference. Now if you're talking like 100 objects then yeah, it might be better to filter out the ones that aren't anywhere near the action.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fanotherpg's Avatar
    Join Date
    Jul 2006
    Location
    High Wycombe, Buckinghamshire, UK
    Posts
    3,665
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using animation check for distance.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Easiest way to check collision between two points?
    By Phanto in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 19th August 2011, 01:01 AM
  2. Distance check bug help?
    By mobichan in forum File Archive
    Replies: 6
    Last Post: 30th January 2009, 04:33 PM
  3. Distance Check(?)
    By lover in forum File Archive
    Replies: 10
    Last Post: 24th November 2008, 12:46 AM
  4. check distance question
    By sollthar in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 23rd August 2008, 12:49 PM
  5. Check distance - what's wrong?
    By Random in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 30th November 2006, 09:36 PM

Posting Permissions

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