PCG - Spawn Actor Node, choose actor with attribute/parameter

Hi!

I’m wondering how to use the “Spawn Actor” node in PCG with a custom actor selected from a attribute and/or parameter.
I noticed that “Static Mesh Spawner” node has an option to choose “PCGMeshSelectorByAttribute”, is there anything similar for “Spawn Actor” node.

I can see that the “Spawn Actor” node has two parameters called “Overrides” and “Root Actor” but I’m not sure how to begin using them, if they are even related to my issue.

using these two attributes can achieve:
bool bSpawnByAttribute
FName SpawnAttribute(ActorPath)

Hey, so you can do this in 2 ways:

The Blueprint wrapper way or simple PCG way, what do I mean with this:

Method 1:

Make a Blueprint and add an actor class variable to it and give it a unique name, add a PCG component with the target PCG that you want to use this blueprint with.
Go to your PCG and add a Get actor property, select it and under the details, Property Name add the name of the actor class variable that you added in your blueprint, add it to a Add attribute and then connect it to a Spawn Actor.
Under the Spawn Actor details, enable the Spawn Attribute property, add the name of the Actor Class variable as before, then Voila, you’re done!

Method 2:

Inside of the PCG go under Graph Settings, Instance, Parameters press the plus button to add a new custom variable/property.
Name the variable and change it to an Actor Class.
On the graph get the actor variable under right click, get name of the actor add it to a Add attribute and then connect it to a Spawn Actor.
Under the Spawn Actor details, enable the Spawn Attribute property, add the name of the Actor Class variable as before, then Voila, you’re done!

Hope this helps anyone who’s looking into this and I’ll be adding a youtube video soon too to explain it better

https://streamable.com/9slo39

3 Likes

Hello,

Unfortunately none of the solutions above are working for me.
Here’s how I got it working:

With actor paths as a string attribute on the points simply use an Attribute Cast Node to cast from String to Soft Object Path type.
If you create the attribute yourself in PCG set it to type Soft Object Path from the start.

Then on the Spawn Actor node

  1. Enable Spawn Attribute
  2. Type in your actor paths attribute name
  3. Set Template Actor Class to None

Make sure your spawn attribute contains proper actor paths, you can copy paste from the content browser. i.e.:
image

(References above are done in UE 5.4.)

2 Likes