The SpawnActor Mistery - A Paradox is Happening on My PC Right Now!

I’m trying to build a function in my Function Library that would spawn an Actor and set a bunch of parameters on it, but it seems the Spawn Actor From Class node is not available because it doesn’t appear in the nodes list (even if I disable the Context option) and if I try to drag it into the blueprint from the Palette it says “Cannot place this node in this type of graph”.

The point with the subject of this post is that I’m currently using a Spawn Actor From Class node in another Function of the same library and it works flawlessly:

It even lacks the WorldContextObject pin!

I can’t reproduce this in the new function I want to build in any way, so I’m asking to you, Awesome Community, some even feeble light on the path of solving this mistery: how it is possible I managed to put that Spawn Actor node inside a Function Library and why I can’t do that anymore?

Hey
I’m not completely sure about the reason but it may be one of two things, or both.

  1. Spawn Actor from Class needs to know it is in an actual level it can spawn something in and in a FunctionLibrary you don’t have the context, and you can call a Function from the Library from any Blueprint even if it’s not a level or something that can spawn actors.
  2. FunctionLibrary can’t execute anything asynchronously, and spawning an actor requires waiting for it to be generated and then return the variable of the actor, so may be FunctionLibraries don’t like that.

You can call Spawn Actor from Class in a Macro Library instead

Thank you for your suggestions @GRIM_Warlock , they completely make sense, I’ll try with a Macro!

Anyway, I still can’t remember how I managed to use SpawnActor in that Spawn Herd function in the same library: I also tried to duplicate the function but the node disappears!

The quest goes on, I hope someone helps me solve this mistery :smiley:

All I can say is “be careful”. There are some things you can do to create Events or call not-allowed Functions like your case in Function and Macro Libraries, and you may even be able to compile the BP, but it will crash or pop an error if you use it.
Don’t know if that might be your case

Thanks for the advice!

I ended up moving the function in the Game Instance BP, so it is available to all levels (currently there’s only one level btw) and I can store/update global data there.

I don’t know if this is correct but it’s getting the job done at the moment.