SpawnActor from Asset

Hello,

i’am new to Unreal and want to spawn an actor, from a assets list, but it does not working, i checked other posts and do it the same way, as the solutions there.

The cast failed, and debug information says “get asset” is the right one and “get class” refers to blueprint class

my blueprint:

some information: the path is not empty, there are 20 blueprint actors and the index is set to 1

whats the mistake in my blueprint?

Already a thank you.

Hey @fecreation! Welcome to the forums!

Could you do us a favor and screenshot the error code you’re receiving? We need the entire thing please :slight_smile: Or really mainly we need the last half or so.


thats the debug information

the objects i want to spawn are blueprint actors from “create blueprint as actor”

Hmmmm. That is strange.

Try Replacing this node:
image
With a “Get A Copy” node. Right now you have “Get A Ref”. You can tell by the output shape (diamond is ref, circle/dot is copy).
I don’t know if that will fix it, but getting a hard reference and then getting class with a pure function seems like it wouldn’t work.

Give that a shot and get back to us! :slight_smile:

unfortunately the same result, I think it’s the cast, if I select the class manually I can select it directly in the “SpawnActor” method as “Base-L_01_01” that’s the name of the blueprint

Can you simply remove the cast and connect through? So that way you could feasibly change the index and spawn the actor just fine? I guess the worry here is that it needs to BE an actor asset to be spawned through “Spawn Actor”, so the class cast is something like a filter preventing non-actors from passing through. But yeah I saw where your issue was, an Actor class was going into the cast but it was returning “Unknown”.

i cant put the “get asset” value in, because its type object and the “get class” value is type object class. so how can i get the correct class from the asset?

there is also a "get object class"method, but they need a Element Handle (dont know whats these is)

What about this?

okay that seems to be a bug, if i put the pin from “get class” into the class pin of “cast to actor class” by hand, it says me not possible, if i drag of the pin from “get class” into the backgrund and create a new node of “cast to actor class” its working :smiley:

but if i run it, it throws the same error as above…

Unreal Version: 5.1.0-23058290+++UE5+Release-5.1

Did you mean to mark this as a solution then?

Try throwing a printstring in before the Cast, and in the output for the printstring plug in the return value and then run the game, see if it’s still returning “unknown”

sorry i clicked mark solution after finding the pin bug but then tested it.

the print string gives me: “[Placeholder_C_2] Blueprint”

Placeholder is the name of the blueprint actor, who runs this at startup.

tested other setup, “get asset” gives me the right class name :confused:

Hmm. Wait, so [Placeholder_C_2] Blueprint is where this code is located?

Or is that what’s supposed to be getting spawned?

And can you be more specific, which “get asset” setup gives you the right class name?

Placeholder_C_2 (dont know why “C_2” is adde) is the Blueprint Actor, who has the code inside its Event Graph. For testing this code i created a new blueprint named “Placeholder” an put them into the scene, then i setup this code to start with “Event BeginPlay”. i want to get a array of all assets inside a specific folder in content browser, then get 1 element of this array with an variable “index” and spawn this element (its also a blueprint actor) into the scene. All around about is to create a buildingsystem in runtime.

i putted a new screenshot there is on the left side a “get Asset” node, look at the “Get Display name” node thats connected from it, there is a “watching string” with a value of “Base-L-01_01” thats exactly the name of the blueprint in content browser and thats also the name of the class i can select manually in the “spawnActor” node.


the red marked is the class i can put in manually

to recreate the process, i created a empty blueprint class called “Z”, is the only asset in the target path folder:
2023-01-12 17_25_06-RPG - Unreal Editor



then use code from above, same error appears…

Try this:

image

It works!

My Products

hey, looks a bit strange to me and out of the standard way, but how can i connect the “make soft class path” to “load class asset blocking”

+got it with the “to soft class reference” node

but the “break AssetData” node has no Object Path Value, seems new in 5.1

5.1

image

same error, i think unreal dont want me xD

Sorry. I’ve just checked and fixed it:

5.1

Working Solution found:
its looks a bit wrong for me to do “make soft class path” but it works fine:

Some Sidequestion:
how can i do “Get Assets by path” only 1 folder deep?

1 Like

Well I’m glad you got something figured out, @fecreation!

As for your side note:

To get some attention for that, go ahead and make a new post! It’s unrelated enough that it warrants it, plus you’ll get a lot of new faces looking at it!