 ## User Tag List

1. 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.  Reply With Quote

2. 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.  Reply With Quote

3. 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 EDIT
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!   Reply With Quote

loops, nested loop, question 