Best way to allow player to place mesh in game world

Hey,

I’m creating a game where the player can walk around an open world landscape setting and they can place houses on the terrain.

  • The house model is a static mesh.
  • The transform values could be different for each house
  • The player places the house by clicking on the floor and a single house model is dropped into that location
  • A player could place upwards of 10,000 houses in the map

My question is, what would be the best most optimised way of implementing a feature like this where the player can drop so many meshes into the map in locations which they choose?

I’ve tried placing the houses using the foliage tool and it works really well. I can have up to 10,000 models using the foliage tool and there doesn’t seem to be much of a performance hit. However, I’m not sure how I can give this option to the player where they can place objects using the foliage tool in the editor.

I’ve tried creating a blueprint with the model as a static mesh, instanced mesh and a hierarchical instanced mesh, but the frame rate drops once I get about a 1000 blueprints in the map. The HIM sounds really good in principle, but it seems to work well if instances are added into the single blueprint. I’m not sure how this can be done in my game where the player is essentially dropping houses in random locations that they choose.

Any insights / guidance would be much appreciated.

Thank you.

Hello,

if you want to spawn multiple objects like Foliage Tool, you can use this : - YouTube

For example, when you LeftClick on terrain in game, you will run a CustomEvent, which will spawn a Box collision, and then like in the video, you take some random points in this box collision, then LineTrace to the ground and you have multiple Spawn Location like Foliage Tool.

However, about optimizations, i can’t help you… =/

Thanks @widzo - its a cool way to spawn objects, but unfortunately I would come across optimisation issues :frowning:

Here is a tutorial on HIM use. I’m guessing that the component itself has an AddInstance() method that will help you place your houses. (I have not used HIM)

However, 1000 blueprints is not a massive amount of polygons so it should not have such an impact on your performance. (unless each house model is tens of thousands of polygons in which case - this is the problem) Reasonably current GPUs render tens of millions polygons without breaking a sweat.

My guess is your house blueprint uses many materials and has no LODs set. This will hurt your frame rate.

Check this article by Bob Cober for additional optimization techniques. Although a bit outdated, it still explains the most impactful and widely used graphic optimization techniques.