How to set up and trigger a chaos destruction in C++?

Having quick-watched all the videos of the Chaos Destruction Learning Path and read the acompanying text, I still don’t have a clue how to go about it.

The documentation of UGeometryCollectionComponent is a little more helpful.

Maybe someone can confirm that the following steps are indeed the steps to set up my chaos destruction:

  • I have a couple of actors, the asteroids, that have a static mesh component that I want to chaos-destruct upon collision (and when the player shoots them)
  • I can add a UGeometryCollectionComponent to every asteroid actor
  • I don’t know how, but I somehow initialize each UGeometryCollectionComponent

First problem here:

When setting up a Geometry Collection in the editor, I click the actor with a static mesh, go to fracture mode and then ‘new’. I can’t find a method in the UGeometryCollectionComponent that allows me to set the actor, static mesh, or collection of static meshes that the component uses.

  • I apply a fracture with some random seed for every asteroid, e.g. in BeginPlay
  • I use UGeometryCollection::ApplyPhysicsField when I want a asteroid to break (I still have to figure out the details here)

Second problem here:

I want the resulting parts of the asteroid destruction to turn into new asteroids, i.e. actors with static mesh component. I don’t know what kind of output the chaos destruction produces and how to get all the resulting actors, if any.

1 Like

My research results in only this, so far:

Geometry Collections are not meant to be created programmatically. When you click on some static mesh in the editor → fracture mode → new, of course behind the scenes there is some C++ that creates the geometry collection but for some reason this isn’t exposed to be used anywhere else then in the editor. (I still have to figure out, if there is a way to work around this)

This is kind of disheartening. Even if I get my geometry collections for procedurally generated meshes somehow, I am actually abusing the editor rather than using it to my advantage (it’s not the first time).

Asteroids that get destructed into smaller asteroids that eventually get destructed just isn’t an anticipated use case for Unreal’s chaos physics.

Have you found a solution to your problem?

as far as I understand, the geometry collections are meant to be used for baked destruction. I.e. fractures have to be calculated in the editor and cannot be calculated at game runtime. And for the moment, I don’t have any indication that this will change in the future.