So in my game Im in the need to have many, many enemies swarm the player at the same time, close to 100 enemies on screen would be a goal I’m aiming for. My question is, of course, how in the world will I be able to have all of these enemies on screen (some off screen) at the same time without the game running at 5 fps. Any suggestions about techniques to use? what polycount I should aim for with my models? etc.
Well I’m asking as in how many ploys should I aim for with my models. It won’t hurt to have a plan, so then I won’t have to backtrack, I can always create models with things in mind, its not as easy to go back and change them.
Besides, I have a placeholder model I made thats around 6k triangles I think and that didn’t seem to work too well, but that’s the lowest Sculptris would bring it down to
But pre-emptive optimisations, to simplify AI, these are just my ideas.
Grouping, drive groups of enemies with basic granular AI code, level of AI e.g. if enemy visible then it needs to react more realisticly than out of sight baddies.
Map the environment to a simplified path-finding grid so the AI can work on a separate thread.
Think of a LOD approach for AI, e.g. you could simulate out of sight combat with Dice roles for instance, but still play the sound effects.
Then you will probably want to setup some kind of scheduling e.g odd/even frames, every x frames for updates again think LOD and player experience.
Mind you if it’s multi-player it might be more complex.
Check out the ios and android optimisations as mobile developers really have tight CPU budgets so they pick up lots of tricks, e.g. Check for layer not name of collision object (int check as opposed to string check).
Sorry thought you meant the code, polys depends on platform/min hardware, scene assets, test and adjust, again look into LOD, far away low poly near high poly, baking occlusion depending on levels!
Okay so lets take it from a scripting perspective. To save multiple scripts from running simultaneously, how would I approach a giant script controlling say 10 enemies? ( This would be simple if the enemies have one target, but they will have multiple targets they will switch back and forth between). Im not asking how toy set and differ between priorities and stuff, I just want to know a beginning approach to making a script that covers 10 separate characters. Or at least point me in the right direction…
Look up list. List lets you have a list with a class. A class will contain as many variables as you want to control them.
Example:
class enemy
{
var obj:GameObject;
var health:int;
}
//name of list is enemyList using the class called enemy
var enemyList:List.<enemy> = new List.<enemy>();
//add one
var e:enemy = new enemy();
e.obj = Instantiate.... // (copy an enemy etc)
e.health = 100;
enemyList.Add(e);
//loop through them all
for (var i:int = 0; i<enemyList.Count; i++)
{
if (enemyList[i].health<0)
{
print("I should be dead!");
}
...other logic stuff
}
I see, so the list just creates enemies with the variables you specify and with the actions you specify all in the same script. So this would create however many enemies you please and they would all follow the same actions and same variables? Thank you Hippo
List is whatever you want. If you want it to be a list of enemies, it is. If you want it to be list of integers it is. You can also remove items from the list and add them in the list wherever you want. List is essential to game development
It’s just like a completely dynamic array. It becomes more powerful if you use it with classes. You can have a class with another list. Or a list of lists that contain classes of lists. Or you can just order a padded cell if you want to go further.