Everything is Blueprint-callable
The actors, the mesh component and the Asteroid Asset expose their settings and actions to Blueprint, so you can build asteroids and fields while the game runs. Generation runs on worker threads: the game keeps running while meshes stream in.
Spawn a field at runtime
- In your Blueprint, add Spawn Actor from Class and choose Asteroid Cluster Actor.
- From its return value, set Cluster Seed, Asteroid Count, Distribution Type, Cluster Radius and Min Spacing.
- Fill Asteroid Asset Templates with one or more saved Asteroid Assets, and Asteroid Materials with the materials to pick from.
- Call Generate Cluster.
- Read Is Generating or Get Generation Progress (0 to 1) to drive a loading bar, or let the field stream in.
Expected result: the field appears around the actor's location and fills in over a few frames. The same Cluster Seed with the same settings and template order gives the same field every time.
Useful calls
| Call | On | What it does |
|---|---|---|
| Generate Cluster / Clear Cluster | Asteroid Cluster Actor | Builds or removes the field members |
| Get Asteroid Count | Asteroid Cluster Actor | Returns how many asteroids the field has |
| Detach Component To Actor | Asteroid Cluster Actor | Turns one member into its own actor, for example for mining or destruction |
| Regenerate Asteroid | Asteroid Actor | Rebuilds one asteroid after you change its settings |
| Regenerate Component Async | Asteroid Mesh Component | Rebuilds a component on a worker thread |
| Create Static Mesh, Update Static Mesh, Replace With Static Mesh | Asteroid Mesh Component | Bakes the generated mesh to a static mesh |
| Calculate Physical Properties | Asteroid Mesh Component | Computes the asteroid's mass, density and centre of mass and stores them on the component for gameplay |
| Randomize Seed, Regenerate Mesh, Save As Static Mesh | Asteroid Asset | Edits and exports a recipe |
One asteroid at runtime
- Spawn an Asteroid Actor.
- Set its shape settings, for example Base Radius, Random Seed and Noise Amplitude, and assign a material.
- Call Regenerate Asteroid.