When there's 1000+ units in map there's quite a lag...
is it possible to reduce this lag by somehow tweaking units' data?
For instance, if a map spawns zealots for each player,
can you delete/tweak zealot's data to reduce lag when it reaches high number?
The game must handle a lot of stuff for every unit. The more units you add the more stuff the game must handle. At some point your computer just isn't fast enough to do everything in real time, so it starts lagging and uses the bonus time to finish it's workload.
I don't know how many units SC2 can handle safely. It also depends on what units (for example battlecruisers have a very detailed model so they need more cpu power to maintain than a Zealot would). You gotta try that out.
In any game, collision handling takes a LOT of processing power. Why? You have to check every single unit against every other unit for every iteration of the game loop. So if you have N units, it takes N^2 operations to test all possible collisions (though this is worse case, it could be much better with some smart programming). Here are some things that *might* help you, not sure, it's just a theory- you will however have to give up collision handling (you'll have a bunch of overlapping units, might be acceptable, might not : P)
1. For each en masse unit, unflag all unnecessary collision flags, particularly the ones shared by the units being massed; if you still want things not to scale cliffs, leave Unused Flag 09 (Ground) checked (though it may behoove you to uncheck it and just remove any cliffs on your map. I would only go through the trouble if all else fails and you have a lot of faith in me).
2. If that doesn't work, then do this too: set all radii, soft and hard, to 0. I'm not actually sure if that will help, but it's worth a try. I'm thinking multiplying real values by OR taking the square root of 0 might be a quick calculation.
3. Pretty much do anything to prevent the units from being "checked" by the game for collisions.
A lot of your problem, like s3rius said, may be due to rendering detailed models. Perhaps just rely more on models with a low count of polygons/vertices/bones/whatever (this can be checked using the model previewer if I'm not mistaken).
The graphics card in particular takes a lot of strain. You can get away with having a slightly greater amount of units on lower settings but when graphics are scaled up, performance drops rapidly. As the others mentioned, 1000 units is overkill .
I dont think rescaling would help, but I am really interested if it would be less lagy with low poly models.
I had trouble on my map with too many units before, I also experienced lag with too many missile.
i would like to find out how to reduce lag also lol..
i have a 12 player autospawning map with 12 heroes on the field (1 hero per player) and a whole host of other shit going on, Lag can get pretty bad for some. over 1000 units is pretty common.
Best bet i would assume is to use low quality models, But that means importing units (Which wastes much needed map space, and there are no ppl making these models) ...So that solution is pretty much out the window.
The removing of collision i definitely cant do , it will break the game , anything else?
Cant you just disable the autospawning once there are more than 200 or 300 units? I mean I can't imgine that you really need 1000 units at once.
By the way have you thought about working around this problem in that way:
Instead of spawning massive amounts of units you just spawn actors with the units model (which should take less performance). Then you just need a trigger system that checks if a player comes close enough to that actor to interact with the corresponding unit. And once this happens you destroy the actor and great the unit. This would make sure that you have only units where you need units, but the map looks crowded anyways.
I'm working on a map where, once I tilted to the camera to a 3rd person view, the graphics became sinfully laggy, even though there wasn't a whole lot on the map. Why? I suspect this was because the graphics card only renders things that are on screen. Therefore, lag may be reduced if you **increase zoom on the camera** so that less stuff is actually being rendered at once. This probably needs to be confirmed with testing, but I think it will help. This may be more feasible and certainly more simple to implement than my last crackpot solution : P
Also, would it be possible to set a unit's opacity to 0% when off camera? I'm fairly sure the trigger logic could be implemented, but I'm not sure that a) you can reduce opacity through the trigger editor, or b) the game is smart enough not to render anything with 0% opacity. Probably needs to be tested : )
Otherwise, a more difficult solution may be to create and maintain an array of points for each "unit" on the map, and once the camera is close enough to the point, spawn the unit, then destroy it once the camera moves away. The unit would only be there for graphical effect, whereas all AI would be handled somewhat difficultly I'd imagine through the trigger editor. Just a crazy idea.
Hopefully you can achieve your goal without a severe work around, but it may take a lot of work to do something that extreme. If you want 1000+ units that badly, you should probably be prepared to insert some "creative" mechanics into your map. The plus side is that the diffculty in taking such measures would make your map unique, because no one would could *easily* recreate what you accomplished. If your map is easy to create, there's a good chance that it doesn't really have anything that seperates it from other maps, right? Even if it's still unique in some way, someone could easily come along and snag your idea, so I say it's always good to make your projects both complicated, difficult to implement, yet modular if at all possible, lol. Best of luck.
im just curious, what amount of FPS gain did u get?
I must admit that I didn't get too much FPS gain (about 8 to 10) but
your method eliminated lag that occur when the spawned units fought each other.
The game is so much smoother now even when all 8 players
are spawning units...I can really see difference.