OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: DrStrangelove on 18 Oct 2002, 17:53:00

Title: Lag when spawning AI units ? Read this !
Post by: DrStrangelove 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.
Title: Re:Lag when spawning AI units ? Read this !
Post by: Hamdinger 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.
Title: Re:Lag when spawning AI units ? Read this !
Post by: CareyBear 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)
Title: Re:Lag when spawning AI units ? Read this !
Post by: KTottE 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.