Good evening, I am creating a space game similar to space engineers, and my dynamic ship is built from thousands of static instances. At first, I had a lot of lag so I found and fixed the sources one by one, such as collision, lighting, and general tweaks.
Now the last problem is the most problematic when the ship moves the game lags, I found out that it’s because I have too many instances so when the ship moves it updates thousands of them to move too. The solution to this problem is quite simple to add most of the instances together, of course, I prefer not to do that because I would like to have armor, walls, and props separated. If I add them all together I will have a lot of mesh duplicates as there is variety in my props.
I thought maybe to add them all together(the props) and just mask the ones that I don’t need, but I suspect it will tank the performance because of the big invisible vertex count.
I would like to hear your opinion, have I missed something? Maybe I don’t know of some tool in unreal? Maybe I just overthinking it, please every opinion helps.
If they are actually instances, there would be no hit at all. So I assume you mean copies of the same mesh.
Even if you have thousands of instances on the screen, the GPU only has to make one draw call, and move them all ( at once ) is just like moving one mesh.
You can turn them into ‘real’ instances in the editor, but you end up with one kind of ‘big mesh’.
I’d suggest something like
because after instancing with that you can still move them independently.
It’s hard to tell without seeing your setup, but drawing a lot of stuff will hit the system hard. Much less so if they are ISM ( instanced static meshes ) or HISM ( hierarchical instanced static meshes ).
There’s a limited number of ways you can do that.
Spawning ( not good for you )
Telling the editor you want them to be ISM/HISM with ‘merge actors’ ( which will leave them as a ‘clump’ )
Instance tool ( worth a shot for the price )
See this classic vid on instancing ( although this guy spawns, it will apply for you if you instance all the ship parts - ( if you have a lot of repeating parts ) ):
Actually, the GPU is fine the problem is in the CPU. If I am correct each instance needs to calculate the rotation and location relative to the component and if you get to a really high number of instances then it creates problems, so let’s say we got 505050 cubes if you create a mesh of 8 cubes and change the mesh inside the component for it then there will be little change in performance. And thanks I will check the link for the tool.
Yeap looks like you were right it wasn’t the instances it was my mistake on my part, had some collisions still on with each new room I added it would add more and more of them. Thanks again.