Download

Hundreds of physics actors are killing the game

I thought I was pretty cool for making a palm tree that responds to physics. It’s a skeletal mesh where the trunk is built up by ten bones in a tail formation, so it can bend if it’s being hit by an object. Skeletal meshes can not be used as foliage. So I instead put the tree in a Blueprint, then I spawn that Blueprint on random locations all over my map.

But once I start spawning hundreds of trees my game dies of lag. At 500 spawned trees the games is so lagged it won’t even respond, and I have to terminate UE.

I’ve deactivated Tick in the blueprint, and it has no functions or any code in it. It’s empty except for the mesh. I’ve even deactivated physics simulation on the tree to see if that’s causing the lag. But no difference.

Is there a limit to how many spawns you can do? It makes no sense, there must be hundreds of spawned bullets in an intense BF4 online match for example. Not that I know if BF4 was made in UE, but still.

whats your draw call count with a few 100 spawned

I guess the bullets are probably particles. Definitely not skeletal meshes. Skeletal meshes are heavy on the engine, the more bones the heavier from what I heard.

A few suggestions:

It might not be the physics simulation causing the lag, it could be dynamic lighting on the trees.

You could try having skeletal meshes only close to the player, then swapping them for static ones as the player moves through the level?

If it is the lighting which is causing the problem, your method of deactivating physics would work nicely in conjunction with my point just above, only turning physics on trees close to the player

I have no idea actually, where do I see that?

You’re right, bullets aren’t skeletal meshes actually. But how about GTA, there are bunches of NPC people randomly walking around. Plus cars.

I don’t think it’s the simulation causing the lag either. I did deactivate simulation all together too see what happens if I just spawn the unsimulated skeletal mesh itself over the map, but it still lags.

But I understand what you mean and I never thought of shadows. Replacing the mesh like you suggest could probably work but I don’t think it would make a difference in my case. I drop bombs from an airplane. I had this mental image of how cool it would be if the trees would react to the blast if I drop a bomb in a forest. We’re still talking about some hundred simulated trees to get a cool visual blast wave effect. Sounds like I have to drop the idea all together.

Do the meshes need to be skeletal? I mean if the plane is pretty high up maybe place the trees still using the foliage tool and use vertex animation? I havent done it myself but you could look into how some people do grass which blows in the wind, it might be possible to do a circular impulse at the location where the bomb drops instead of a linear gradient to control the animation. (I might be wrong here but I think that way they could still be static meshes too therefore could still have lighting built on them)

in the consol type [stat engine] without brackets to see the call count stats.
im guessing each bone is a draw call, @ 500 trees x 10 bones your hitting 5000+ draw calls which is way to much for dx 11 to handle. 500 meshes is nothing, i have over >600k< trees in my level, the trick is they all have to be instanced

there are def a few ways to get what you want
this post has some great ways to interact with grass
45078ecd016a4ee49724991ba7cb0922a5c98825.jpeg

and there is this video

That was actually a good idea, and I even experimented with the World Offset node in the material. I soon discovered that you cannot set an individual material instance on an instanced mesh (foliage). The mesh is a clone, so each and every instance shares the same material. Meaning ALL trees will react when I change the material.

I think I’m going with this idea. Replacing instances of foliage trees with blueprints. I tried doing it with the skeletal mesh but it starts lagging around 50 trees or so. So I’m replacing the trees with a static mesh instead, with physics enabled.

It’s not the “wave” effect I had in mind, but at least the trees fall over and even blast away when I drop a bomb nearby. It’s better than nothing.