RTS Unit handling

Hey,

I’ve been wondering about efficient handling of RTS units… Instantiating seems the easiest way (although I HATE the idea on principle), but units are only going to pop out once every few seconds at peak load, where I would then feed them into a fixed-length array where I control everything from.

So long as all explosions, bullets, recyclables etc are handled in a circular system (no instantiating), and only units themselves are initially instantiated (most likely i’d be doing a garbage collect when the user changes the view back to the base anyway), am I going to hit a slow down?

Thoughts? This isn’t for a real project… yet… Just something that’s been bugging me.

With the caveat that I’ve always been a fan of optimising only when needed I would say…

Instantiating isn’t that expensive, I doubt you would notice an effect it at a rate of 1 a second.

The other issue you could run into with an RTS type scenario is pre-instantiating everything is going to cost a lot of memory.

Maybe the ideal is some kind of “intelligent” instantiation strategy…

  • Look at the units queued to build, possibly even predict what kind of units are likely to be built next.

  • Create a queue of units to be instantiated.

  • Instantiate these when load/memory/frame-rate allows it (or when unit is built in the worst case).

I second JohnnyA on this. No much impact of instantiating units, except the first time you do it.
For my RTS/TW def game, I use pooling only for missiles and GUI stuff.