WelshZeCorgi Posted May 9, 2022 Posted May 9, 2022 I want to make a mission that has hundreds of units in order to try to make it feel like a living breathing world, but it seems to really hurt the frames. Is there a way to mitigate that? Is there a way to despawn units and does doing so reduce the workload?
cfrag Posted May 9, 2022 Posted May 9, 2022 (edited) 1 hour ago, WelshZeCorgi said: Is there a way to despawn units and does doing so reduce the workload? One possible approach is to despawn the 'eye-candy' units (e.g. from the airfield that you departing from) when you are far enough, and similarly spawn ornamental units only when you get close. Also, use statics instead of groups as mobs require more cpu (for their AI) - which is the answer to the latter part of your question. Any units that you place eats up some cpu - at minimum it has to be tracked. Not all units are equal, and their position relative to you (or other players) is relevant. Statics require no AI, and when units are outside of your view, they also do not require rendering. So a possible approach is to subdivide your mission in sectors, and only spawn those units that are relevant for that part, and despawn all others. This will conserve cpu, but can lead to complex mission design schemes that ensure the correct units are alive, and that there are no obvious breaks in continuity. So how do you despawn and respawn units selectively? You will need Lua, and (to make it simpler) some libraries that have ready-made functions for this. Edited May 9, 2022 by cfrag 1 1
Recommended Posts