Magnitude and multiple actors
jmachado999
Member Posts: 52
I am having a bit of a logic issue and I am wondering if anyone can help shed some light on this for me.
I have in a tower game, dynamically spawned towers and enemies. I am tracking the positions of said actors in tables so I can calculate magnitudes.
The issue I am having is that I would like to loop over the tables in my tower actors so they can determine the distance from all dynamically spawned actors and determine who is closest and then fire if in range.
I am not certain how I would loop through the tables to check for all of the magnitudes from all of the different towers.
Any help would be appreciated, I am hoping talking this out might help reach a solution.
Thanks in advance.
Jason
Comments
I wonder if creating a new table with towers on one side and enemies on the other would be a place to start, then loop through the enemy table calculating magnitudes for each on screen enemy. I think that might be too taxing on the system though due to all the timers that would be involved.
Is there an easier way to loop through tables that I am over looking?
Jason
@jmachado999, the loop over table would not be very taxing as it would only calculate one magnitude per game cycle. So, you need to be aware that if you have 10 enemies, you will only get a result (closest enemy) every 0.2 seconds per tower.
Also, the loop over table can not be nested.
If you have a moderate number of towers and enemies, it is worth investigating putting a loop over table in each actor, instead of a single controlling actor doing all the processing.
GS can handle a lot.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch
Thanks for the insight, would you mind elaborating on the loop over table? I am not sure I know exactly what that is.
Also can the tables be created dynamically via the actor?
Thanks again