User Tag List

Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 39

Thread: Calculating distance: Adv Direction Object vs. expression

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Calculating distance: Adv Direction Object vs. expression

    I am needing to optimize my game and wondered if anyone can say which is more efficient at calculating the distance between 2 objects? When the player moves I run a for each loop on all obstacles and store their distance to the player in the obstacle's alterable variable. Right now I use the Adv Dir Obj "distance between 2 objects" expression. But I am curious if it is faster to use the equation for distance?

    Anyone know if there is any significant difference between these two approaches? I am exporting to mobile as well as windows if that matters.

  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,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Unfortunately I don't know,
    ....why don't you try testing both on your code and tell us the difference, if any?
    Since you already have events positioned and if expression to change is only one...
    maybe just output-ing "timer" value right after loops are being performed in situation A and B to see if significant difference arises
    (I would be curious to know as well! )

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Yea I thought I had read a post some time ago discussing the difference but can't find it now. That was why I made the new post, in case someone knew off the top of their head. I am not sure how to record the timer value or even if it would register a difference. But since it is possible I will be scaling this loop over the course of the game from around 10 to possibly 50 or 60 objects I am worried thing will get slower as the game develops.

  4. #4
    Clicker Fusion 2.5
    Bertard's Avatar
    Join Date
    Jan 2014
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For calcule a distance it's

    (X("Item A")-X("Item B"))pow2+(Y("Item A")-Y("Item B"))pow2

    Program of fifth form class

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Thanks Bertard. I know the equation but I wonder if it is more CPU intensive for mmf to process the equation than to use the advanced direction object expression.

  6. #6
    Clicker Multimedia Fusion 2 DeveloperiOS 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)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How bout creating a new App with 200 Objects, and let them Allways calculate distance to random points and see if the frame drops?
    Dont know if that will be enough to make the frame drop or not though.

  7. #7
    Clicker Fusion 2.5
    Bertard's Avatar
    Join Date
    Jan 2014
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand what you want

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    So, after trying a raw equation: sqr( (X.a-X.b)pow2 + (Y.a-Y.b)pow2 ) and the Advanced Direction Object's expression "Distance between 2 objects" I am finding almost no difference when running on a mobile device. I would be curious if anyone knows if there is an efficiency difference between the two methods, but for now I guess there isn't a clear winner in my project.

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,247
    Mentioned
    87 Post(s)
    Tagged
    0 Thread(s)
    Try this MFA.

    Seems to makes little difference on my PC. Though this doesn't measure the timer, but just goes by framerate. I got 5 FPS using each method (30,000 calculations per second, randomly selecting from 18,000 objects)



    You might want to try it on your output platform and see if you see any difference, and/or add code to make it test the exact time elapsed.


    Attached files Attached files

  10. #10
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,247
    Mentioned
    87 Post(s)
    Tagged
    0 Thread(s)
    as an aside, the actives in that screenshot were all placed "randomly". It's interesting how a clear pattern is visible. I guess true randomness is as elusive today as it ever was.

Page 1 of 4 1 2 3 ... LastLast

Similar Threads

  1. Advanced Direction Distance Bug
    By Kid_Roleplay in forum File Archive
    Replies: 0
    Last Post: 14th September 2013, 05:35 AM
  2. one of the same active object distance
    By bubba_damage in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 31st May 2009, 07:15 PM
  3. Distance between objects with advanced direction?
    By Skeets in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 20th December 2008, 01:25 AM
  4. Calculating Distance from Player
    By Zenoff64 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th January 2008, 02:18 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
  •