Home   Help Search Login Register  

Author Topic: Lag when spawning AI units ? Read this !  (Read 1054 times)

0 Members and 1 Guest are viewing this topic.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Lag when spawning AI units ? Read this !
« on: 18 Oct 2002, 17:53:00 »
Hi. While working on my dynamic nam scenario i had some situations where spawning AI units produced no lag at all, while in other situations even spawning a single soldier the game lagged heavily. Did some tests and thought i let you know.

It's not the CreateUnit - command that lags the game, it the loading of units & their textures (i guess).

For every unittype that you want to spawn during your whole mission, create a unit in the editor.
It doesn't matter if you use it as a dummyunit or use it for doing a 'real' job in the mission, it's just important that it exits from the start on. That way all unit & their textures are loaded into memory at missionstart.

I spawned a whole group of 12 vc without even noticing a little lag (i was flying a chopper) !

If this is info already known, sorry for wasting your time. It's just that i never read that anywhere here in the editing/scripting area.

Hamdinger

  • Guest
Re:Lag when spawning AI units ? Read this !
« Reply #1 on: 18 Oct 2002, 19:32:13 »
I've noticed this, too.  I think it also applies to vehicles created with createVehicle.  If you don't need the dummy units, you can put them in the radius of a trigger that calls deleteVehicle on everything after a few seconds.

CareyBear

  • Guest
Re:Lag when spawning AI units ? Read this !
« Reply #2 on: 19 Oct 2002, 19:08:55 »
Yes, this is correct (to the best of my understanding).

This is also why you should be careful about the *variety* of units you use in a mission, as each unit type and vehicle type (and, for that matter, object type) that you use in the game requires memory - so for a mission to be more playable on a low-spec (esp low RAM) puter, limit the different types of units you use. The effect is not great, but when it comes to optimisation, it's all about the little things - as many of them as possible. It's easy to get carried away and put in one of everything..  ;D

I'm not sure about this, but I believe that you can put "deleteVehicle this" in the init of the unit, and the object file and textures will be loaded even though the unit never appears in your mission.  8)

Offline KTottE

  • Former Staff
  • ****
Re:Lag when spawning AI units ? Read this !
« Reply #3 on: 19 Oct 2002, 19:52:39 »
You're correct in your thinking there Carey. Before the init fields are executed, the mission must be loaded, and it is in this phase that textures and so on are loaded up.

So a deleteVehicle this in the init field will work just fine.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"