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

9 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.)

7 Likes

Big thx) Your answer is really help me)

I couldn’t get it to work in 5.5 using Spawn Attribute.

Here’s what worked for me:
Added Soft Object Path Attribute as described above.
Set TemplateActor to the class i wanted to spawn (LevelInstance).
Used Spawned Actor Property Override to set the object path.

3 Likes

i just spent 4 days struggling with this, even with all the help in this thread, so i figured id post up my solution here for anyone else who might find this thread.

i’ve been seriously pulling my hair out over it. :sob:

this is using engine 5.6.1

first i added a layer to my landscape and just called it actor so that id have that attribute available on all points generated in my pcg.

then i added a variable called ‘ActorSoft’ of type ‘soft object path’ to my blueprint and made it editable.

then in my pcg graph i used a match and set node to take the blueprint ‘ActorSoft’ variable from the blueprint and set it to the ‘Actor’ attribute from the landscape layer. the match and set node was left using all defaults.

on the spawn actor node i checked the ‘spawn attribute’ box and told it to use the ‘Actor’ attribute that id just set. i left the template actor class as none.

then finally in my level i just dropped in my blueprint and used the property to set whatever actor i wanted to spawn.

now that i’ve done it it’s quite simple but it seriously has taken me days of screaming at my monitor so i hope i’ve written this clearly and it helps anyone else having similar struggles. :v:

1 Like