Starter Example
To get familar with the core concepts, let us start with a simple example. In this example, we configure randomly spawned Pickups in the level after it is loaded.
Prepare the Table
First, we prepare a data table as the pool which the Pickup Actors are spawned from. Right click in Content Browser, find and choose Data Table. On the window following up, select FSpawnEntryTableRow_Actor
as the row type.
Now add a few rows to the table. Assign your Pickup Actor classes to each row for spawning. Make sure the weight is above 0 to keep the row possible to be chosen.
Place the Actor
Spawn Query System plugin provides an actor SpawnScatter
for spawning actors after the level is loaded. Navigate to the toolbar and click on "Place Actors" button. Search for "Spawn Scatter". Place it in the level where you like.
Change Amount
property to 5, and Scatter Range
property to 3. We're generating 5 objects randomly in a circle of radius 3.
Click on Spawn Query
property. From the menu popped up, choose "Create New Asset". The SpawnQuery graph dictates the Actor to generate for each request.
Edit the Graph
Now open the Spawn Query asset you just created. You will be brought to a graph view, and a ROOT
node should be in the center of it.
Right click anywhere, create Sample/Pool
node. Connect the ROOT
node to the pool node.
Select the pool node and assign the pool table to Pool Table
property on the Details panel.
Now you are set.
Test
Enter PIE mode, and you should be able to see 5 Pickup Actors are spawned randomly near the Spawn Scatter
actor.
See Also
ASpawnScatter
can be extended in Blueprints for custom behaviors. See Blueprintable Types.