Crafting Game, trying to make all props destroyable without killing FPS

So I have a rudimentary plan to make a crafting game, my comparison would be Valheim but Fortnite is also similar in theory and at least I know that was made in Unreal so it can be done.

So ideally everything in the game would be destroyable (not talking about destructible meshes here), cut down trees, knock down walls, crush boulders, etc.
I’d like specific particle effects, sounds, animations per item being destroyed and then it drops a certain type of material used for crafting walls, floors, tools, whatever.

The problem I’m having is that I know how to do all this with Actor Blueprints, but having hundreds of them in a level (which is inevitable in a open world game) absolutely destroys FPS.

How does Valheim do it where you could be standing in a forest with hundreds of trees and player made houses made from small pieces?
Or in Fortnite where a single building is obviously made with dozens if not hundreds of destroyable walls and floors?

Can static meshes be used in place of an actor blueprint and still be editable, have specific commands attributed to them? Or is there some way to only render the objects as static meshes until they’re being interacted with? Is this something destructible meshes would be used for and would that help FPS?

developers will use what is called “culling” and “level of detail” aka LOD

look up some tutorials like “ue4 lod” or “ue4 culling” to learn more

The answer to your last paragraph depends on the physics engine you’re using. If you’re using Chaos Physics, they detail in the documentation how to cull destruction.

it will take a bit of research but you can do it, dont give up :slight_smile:

i forgot, they will also set the “state” of the physics object based if there’s a player nearby. For example, all objects start out in the sleeping state, until a player walks within like 10 meters of the object, then it wakes the object

I think a good thing to remember is just how much game design is basically smoke and mirrors. Not an direct answer per se; but how I handled this was using a master blueprint that handled every actor in the world using HISMs.

When the player interacted with something I would then remove the HISM and spawn a blueprint specific to what the player is interacting with.

But I am not a good programmer so it wasn’t as good as it could be and I could never quite figure out how to make it instant as having lots of hisms would cause a slight hitch when being destroyed from it’s array.

Stuff to think about I suppose.

I could never quite figure out how to
make it instant as having lots of
hisms would cause a slight hitch when
being destroyed from it’s array.

Instead of removing the instance, you update its transform only. You move that instance where the player cannot see it / interact with it; and only then spawn in a new actor. The data is on the GPU, it costs virtually nothing, the HISM needs no other updates, and also does not need its state flagged as Dirty.

As a bonus, you get to keep the index order. Although this depends on culling in case of HISMs.

could you (or someone) explain the proper workflow to achieve this properly?
In a previous project I used the player BP to detect foliage static meshes nearby using tick and replace them with interactable skeletal mesh BPs (so they would move/get pushed by the player) and then on the skeletal mesh BP I’d use tick again to determine if the player was far enough away to revert to a static mesh again.
I’m under the impression that tick is something of a last resort and shouldnt be used like this though, as in an example like this, there could be dozens of BPs in range all using tick. Moreso even, if I were to make a multiplayer game, with lots of these BPs in range of multiple characters.

How does a game like ARK do it, where theres dozens of players running around and blowing up extremely complex player made castles without (much of) a hit to FPS?

I know about LODs, distance culling and using ISMs, I’m specifically asking about the BP scenarios and how to achieve having hundreds of BPs on screen/in range at one time.

I’m not sure how to do that specifically but I’d at least look at optimizing everything as much as possible then going a step further and replacing all tick events with a timer instead.

Hey I know this is old, but if you are still around I am curious if you are certain of this performance scenario you mentioned.

I have 16 different HISMs that each have roughly 20,000 instances each (around 350,000 total instances). I was getting a hitch removing the item from the array on swap and had the same idea you did: Update the scale to 0 instead, and back to original if I need it back.

However I get the exact same hitch if I update the transform that I do if I remove it from the array. This is in-editor and I plan to test it in a cook, but I am curious if you are certain that updating a HISM instance transform in a large array has nearly no impact at all.


Are you doing it in a blueprint loop? If so, how many? Are using the batch option?

Loop iteration in BPs is painfully slow.

I am actually only removing one, so it isn’t in a loop. Just this call made once.

If I break that pin, then the hitch is gone. Granted it spawns tons of actors due to it overlapping the spawned actor, but all those spawns are hitchless.

I just did a simple test in 5.2 with a clean first person project. I spawn 100k instances of a cube at begin play and set the transform to all zeros on hit and I get the hitch there too.

I am not. It is a slow operation. You probably mean:

The data is on the GPU, it costs virtually nothing, the HISM needs no other updates, and also does not need its state flagged as Dirty.

I reckon I misspoke, I wonder if I had Custom Primitive Data on my mind back then. Currently, I’d say that modifying an instance’s transform undoes all the benefits (H)ISMs offer.

However, here this is tested on an ancient potato 4c/4t CPU from 2012 I use for this purpose exactly; 27k instances:

Seems to behave as expected. Could you try removing Hit Item and see if it creates a similar hitch on your end?

My code previously was removing the instance and that caused a hitch. When I changed it to modifying the transform the hitch is exactly the same.

When I made my little 5.2 test I had to generate 100k instances to see the hitch. I did 20k at first and didn’t see one (like your test here). But my game implementation is 16 HISMs for between 20-25k each for a total of 350K or so.

It is curious that you can use “Hit Item” from the HitResult. In my “On Hit” code above that data does not reflect the instance hit. I have to do that sphere trace trick to find the instance index.

Here is 100K instances using RemoveInstance.

I was hoping to simply “hide” the swapped instance somehow and schedule it for removal from the savegame during the next load game. When I thought of the idea of setting the instance scale to 0 and then found multiple threads here on the forum suggesting just that (including this one) I thought I had found the answer.

What makes you feel that modifying a HISM Instance transform undoes its benefits? It seems like that is the defacto way to simulate its removal. We know removing it is heavy because it causes a reorder of the entire HISM array.

I’ve just run into this. Perhaps you can skim it and see if anything looks interesting.

I’ve never experienced behaviour you demonstrated and cannot reproduce it in UE4.