User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 13 of 13

Thread: Question about Loops and Nested Loops

  1. #11
    Clicker Fusion 2.5

    Join Date
    Aug 2015
    0 Post(s)
    0 Thread(s)
    The drawing of the vector field (displaying an animation frame) would simply be for development and seeing it work.

    I was originally thinking to calculate and then store the vector value based on the surrounding tiles so that instead of calculating for each unit on the tile, they would just reference the single value and set their direction to that. My game in mind was a zombie-style top-down shooter where the player runs around trying to stay alive, so the sheer number of zombies (as the difficulty progresses) would probably require computing once per tile rather than once per unit on a tile.

    I'm no programming expert. If I chose to calculate based on neighbor tiles, how would I do that as efficiently as possible? I'm working on trying to use an array but it isn't quite working properly yet.

  2. #12
    Clicker Fusion 2.5

    Join Date
    Aug 2015
    0 Post(s)
    0 Thread(s)
    I will NOT need that many units. My ideal game is a zombie shooter and there won't be more than 250 zombies probably depending on how Fusion reacts to that. I think I got the vector value updating to work, so I'll now work on optimizing the distance-step part and likely come back with questions on that.

  3. #13
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    28 Post(s)
    1 Thread(s)
    Sorry, I said "drawing" but I meant "calculating", that would be anyway a performance hit.

    The array is likely your best bet,
    sorry for the question: do you plan to allow multiplayer on this game?

    If not, you can avoid recalculating the first step for each zombie, making for just one pathfinding call (reading all cells from target position) for all the zombies whenever their target is the same
    (but that could also be done with multiple players by calculating N different path maps for N different players)
    this is something some pathfinding engines do to lower calculations (my widget does it i.e.)
    so calculating 100 paths to a single target counts much less than calculating 100 paths to 100 different targets

    Another idea, when you have a grid of distances (step 1)
    you can simply do something like this (assuming the grid is stored in array where Z=2 is the dimension for the vector field):

    for each zombie
    value at (zombieXY/gridsize - Z=1) > 0 (the vector is calculated)
    >>> zombie looks at vector direction

    for each zombie
    value at (zombieXY/gridsize - Z=1) = 0 (the vector is NOT calculated)
    >>> start loop "calculate vector field" (for this cell)
    >>> zombie looks at vector direction

    so following zombies will inherit the calculated vector
    but you wouldn't calculate unnecessary cells
    (hardly your zombies will cover the whole play area?)

    You can also see this awesome example by SolarB, that I think implements a similar solution to increase performances with swarms:

    Having a "sheer number" of objects isn't generally possible in Fusion without hitting some performance walls
    it's likely you'll end up with some headaches with this ..
    but will surely be an interesting challenge

    wrote this after seeing you need 250 units - then I think you can have that!
    More so I think calculating the whole vector field would be less efficient than choosing one of the options above
    let us know what you end up doing and how performance goes, your project looks interesting!

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Nested ForEach loops?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 10th March 2017, 05:05 PM
  2. Nested Foreach loops
    By Pixelthief in forum Fusion 2.5
    Replies: 6
    Last Post: 8th June 2014, 05:52 AM
  3. Nested Loops and cycling properly
    By rubes in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 26th January 2013, 04:48 PM
  4. Nested loops and get loopindex
    By Shadoku in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 27th September 2007, 04:13 PM
  5. nested loops
    By westray in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 14th December 2006, 04:00 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