User Tag List

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

Thread: Fastloops causing slowdowns. Workaround?

  1. #1
    Clicker Fusion 2.5

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

    Fastloops causing slowdowns. Workaround?

    'Ello again, all.

    I'm experiencing quite a bit of slowdown in a project of mine with what I think primarily involves the AI code and Fastloops in an RTS-style game running at 50 FPS. After about fifteen or so enemies on screen/ in the frame at once, the game starts slowing down, and if there's too many enemies, it downright crawls. What I'm looking for is advice on how to optimize my code better to try to prevent possible unnecessary Fastloops. Running it in HWA/ Direct 3D9 speeds it up a tiny bit for me, but I want the game to be able to run with unnoticeable performance issues even on the Standard display mode.

    I'm wondering if there's a way to select individual objects and the objects they're grouped with (like shadows or detectors or bullets) without using Fastloops, and also while keeping MMF2 from picking every instance of the object and having it act like only one of them. A lot of the AI uses distance floaters grabbed from the Advanced Direction Object and stores them as Alterable values as well, so a lot of objects have individual values for how far away something is from them, then constantly search to grab those Fixed values from them. Is there another, less resource-dependant way to do this?

    It makes me wonder how larger 2D RTS games, like Starcraft, can handle so many units. But then, Starcraft also runs at 24 FPS normally...

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Both object pairing and distance checking can be done super fast with action loops. Obviously some things can only be done with fast loops, but in many cases you should opt for action loops or use the ForEach object. I get about 800fps with this example:
    Attached files Attached files
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never heard of the ForEach object before... or "action loops" either. Maybe my comp is on the slow side, as I only get 650ish fps when I run that. Are there any tricks to using that when it comes to a lot of different enemy types with AI and shooting projectiles and the like?

    What I've done is, on the creation of an object, it'd have an internal Flag 0 set to "OFF". Then on another line, where a condition would look for that flag, it'd set it to "ON" while also creating its paired objects and within those paired object, an Alterable Value would be set to the Fixed value of the first object. It helped really well to keep things together, even when it came to that object and its pairs being destroyed in various ways, but seemed to need a fastloop to work.

  4. #4
    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
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    LB's example is great for object pairing but if you want to check the distance of each active against every other one (as you would need to for RTS style AI) you would usually need to run a loop that stores the distance from the selected active in an alt of all the other actives, then pick the closest one to do actions on.

    There's an example of this here: http://www.create-games.com/forum_post.asp?id=295472

    Or alternatively you could check out my example - using a slightly different system - if you want to reach > 500 units: http://community.clickteam.com/showthread.php?t=72110

    Good luck!

  5. #5
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, I know. I've gotten that to work, and really, my own code works just fine! ... Except for the slowdown when it comes to only a handful of objects (units?) being on screen or just anywhere on the frame at once, and even if they're just sitting there, which is definitely a consequence of fastloops. It gets worse once they start firing (more objects, and even some of those are looped, depending on how they behave as a projectile), but I've a sad feeling I may have to recode the entire AI from scratch. I'm about to go to bed though, so I'll have to check the example tomorrow!

  6. #6
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LB is my hero as always. =]

    Are ForEach loops always faster than Fastloops?

    I've replaced all fastloops for every enemy object I have in my game, and slowdown has been considerably reduced! Although some still exists, primarily when enemies decided they all want to target and shoot something simultaneously, and as such, slowdown has to do with object spam at such points; but I have a few things like the player and player weapons still on fastloops. I thought that they'd not be too bad since most of the time there's only a few projectiles being fired, but if ForEach loops or Action Loops are still faster. The weapons themselves I've noticed hadn't seemed to have contributed to the slowdown before, but still in some situations, the framerate drops below 50.

    And also, to reduce objects, would something like raycasting be faster to process as opposed to separate projectile objects? (I have three objects per bullet, usually). If I knew how to make a bullet instantly appear where an enemy is aiming and also hit obstacles if missing, I'd put that in.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    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)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kid_Roleplay - you might find Chris Burrows tutorials useful: here's one for fast bullets you might be able to adapt: http://www.diybandits.com.au/MMF/tut...pbullets1.html
    It uses fast loops, but you might be able to adapt it to use ForEach. He also has some other good examples and tutorials that might help.
    Good luck!

  8. #8
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    x.x I've got soldier units who all fire multiple bullets, three times per burst. Each burst, they create an invisible detector object for the traveling bullet, an invisible detector at the destination the bullet will go (not necessary for some weapons), the bullet that the player sees which is assigned an angle during that burst, and a glowing overlay. Twelve objects. When you have a lot of soldiers firing, that quickly gets overboard, and though my machine can handle a bunch of them already, it still causes slowdown, yet I'm looking to have even more enemies than should probably be, since they're a really disposable enemy.

    What I'm wanting to do is replace the current projectiles with an invisible bullet system to reduce objects, processing (defining angles of the sprites and the paths at the instant of firing, and multiple times), and also some sort of illusion of firing three times and instead only firing once--I'd just make a three burst sound effect or something. A raycasting idea came to mind to help with obstacles it may hit as well as maximum firing distances. I'm wanting the shots to be instant and appearing on the target but not undodgeable. That kind o' thing. ^^;

    But all of this only if some kind of raycasting thing would be the way to go about it. For all I know, that might slowdown the comp even more if ten to twenty units are sending them all at once.

  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)
    1. you don't need to create a separate detector object for collision. put it in the bullet object's animation using the animation swap trick.

    2. what is the detector at the bullet target for? I have a feeling you don't need that either

    That would drop your object count down significantly.

    edit: 3. if the bullets are supposed to be instant, why do you need a graphic or glowing overlay for them? I might be slightly confused on that one

  10. #10
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) What's the animation swap trick? o.o

    2) The detector at the target is for the maximum range of the bullet. In the case of the soldiers, it was removed, as I wanted their bullets to always travel to its maximum range, which was an alterable value used for a "life timer." When the value would count down to zero, the bullet would be destroyed. For tanks, the bullet would be destroyed if it hit that detector, which position varied depending on where the target was.

    3) The bullets aren't instant at current. I'm wanting to come up with a way to add an instant system that'll target what's being shot at but also appear to hit a wall or other obstacle further beyond it if it's inaccurate. If I replace it with an instant hitting code, then I'd have no need to draw the projectile, glowing sprites, or detectors at all.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Fast forward and slowdowns
    By Evilized79 in forum iOS Export Module Version 2.0
    Replies: 12
    Last Post: 14th March 2012, 09:06 AM
  2. Non-Unicode Workaround
    By Ham in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 2nd March 2010, 11:01 PM
  3. animations/actives cause FPS slowdowns?
    By N64Mario in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 21st November 2009, 06:53 AM
  4. Layers Toolbar slowdowns
    By Tiles in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 20th February 2008, 03:21 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
  •