My purpose is drawing a large number of people in the city, similar to SimCity people. It requires:
The people move on path and can disappear when get into the house.
Each person (or group of people) can disappear when a specific event happens (for example: the house near that people is destroyed)
I’ve checked the DrawMeshInstancedIndirect example (github) and see that the draw mesh is moved with the shader file, not C# file. So I don’t know if it’s possible to use DrawMeshInstancedIndirect to populate the people with the requirement above?
You’'ll need an entirely different solution, and it will require a high LOE (level of effort), to include character models, rigs, animators, navmeshagents and a lot of coding. Sorry for the disappointing answer. The amount of time and resources to create the SimCity people is likely in terms of months to years and millions of dollars. Unity only provide the “dials” to create a world, but you have to setup, code and configure every dial, and there’s hundreds of them, that you control using the editor and by writing code. I’d guess that there’s about 200,000 lines (or more) of code that creates and controls the people in SimCity (and not including the environment).
Use DrawMeshInstanced() instead of DrawMeshInstancedIndirect().
Requirements:
The people move on path and can disappear when get into the house. → You can pass the array of transform (which is position/rotation/size, use Matrix4x4.TRS() to set each of them) to control the peds movement.
Each person (or group of people) can disappear when a specific event happens (for example: the house near that people is destroyed) —> Unlike DrawMeshInstancedIndirect(), with DrawMeshInstanced() you can easily call multiple DrawMeshInstanced() each frame, so make each DrawMeshInstanced() a group of ped, if you want a group of ped disappear then stop calling DrawMeshInstanced() for that group of ped.