Procedural Placement of Physics Objects? (instanced or not)

I’m trying to place a bunch of the ‘starter’ blue chamfer cubes in various structures so I can have fun knocking them down. Previously, I did this by manually arranging them:


Big pain in the rear. I started looking into using blueprints and construction scripts to place static meshes along splines (or otherwise procedurally, even just a simple stack) and things were looking up, except I can’t seem to figure out how to enable physics for procedurally placed items. It seems that instanced static meshes can’t have physics and without using instanced static meshes, I can’t figure out how to add multiple copies of a mesh to my scene procedurally.

For example, I’d like the tilted stack in this picture to be affected by gravity and fall:


There’s gotta be something I’m missing here, but I can’t seem to pin down what it is.

If you add the ISM manually, apparently, physics isn’t an option… :melting_face:

( look in the details panel ).

But, as static mesh components, you’re fine :slight_smile:

Performance wise, you probably want a custom geometry collection of some sort.

Something that won’t cost you 1 drawcall per item until it really has to (when you start the simulation).

What @ClockworkOcean is trying to say is…

Make an actor, add the components to it procedurally as children.

My 2c take on it is, make a blueprint that spawns in static meshes however you tell it to.

Same difference really, its just that his way you can control them by moving the actor.

My way you have individual control.

If you have the script run as a bluetility you can spawn instances into the level and save the level, so you don’t have to run the script any time it loads.

Undortunately the actor way doesn’t allow this, only if you add meshes into the level as individual elements.

You can parent them to another actor however, while it won’t allow you to move them as a group, it will allow you to loop the children of the actor to do stuff with…

1 Like

Hmm. I was really hoping I could get something in a construction script so that I could see the results of my procedural placement blueprint in the editor. For example:


I did that by manually stacking 10 cubes, then making a blueprint of that, then setting up ten or so of those into a quarter circle, making a blueprint of that, and so on. But that approach is extremely time consuming and I can’t easily adjust lots of stuff I’d like to (concentric circles, making a dome, etc.)

I tried setting up the ‘stack’ logic with a mesh spawn actor on ‘beginplay’ but A. I couldn’t see my results in the editor, and B. It didn’t behave as expected.

EDIT: Basically, I’m looking for exactly this functionality, except with physics enabled on the placed meshes. I understand that instances are doing some funny stuff on the GPU that the CPU doesn’t get to see, but is there any way to ‘realize’ them into actual static meshes? To some extent I don’t care too much about the performance hit, I just want to have fun knocking over blocks.

You can make them from one BP. Add them as mesh components. But, when you’re ready ( to save the level ), the same BP can spawn them in as static meshes, with physics enabled.

If you make the spawn code hang on a custom event, which has ‘call in editor’ enabled. You can spawn with using run time.

Look.

If you are dealing with that many things…

Use an heirarchical instanced mesh without any simulation.

Then make a blueprint that removes the instance and spawns in the same object as a simulating one when it is needed.

How you determine when it is needed is really up to you…

I’d only bother with direct collision from one object, and “self collision” (its not self collisoon but the idea is that the object you spwan can and will wake up whatever it touches so that you can have a domino effect).

Because it uses engine physics its always going to be finniky.

But doing it this way you at least have a chance at getting some perfoemance…

Btw, this isnt too different from

It works on foliage, for foliage, but foliage is a special instanced static mesh system.

Sure, there havent been any situations where one foliage falls on another creating a chain reaction, which is closer to what you want. But nevertheless, it shows its possible to replce an instance on the fly without much effort or anyone being any the wiser…

I finally found a solution in another thread, and it’s as easy as I’d hoped!

From that thread:


I just added a ‘Set Simulate Physics’ node after ‘Set Relative Location’ and wired in execution and for ‘Target’ wired in the ‘Return Value’ from ‘Add Static Mesh Component’.

Like I say, it does work with components…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.