Spawn Actor in Function Library?

Hi,

It doesn’t seem to be possible to use the Spawn Actor of Class BP-node in functions that are in a Function Library asset.

I’m sure there’s some logic behind this, but I’m curious as to find out what?

Thanks,

I’m not at my computer right now, so I’m working from memory/guessing, but it’s probably because anything can use a function library, and not all objects could spawn an actor, like widgets, etc. I can update this when I have a better explanation. :smiley:

Oh! Hm, I’ll experiment with some casting then. Thanks

i have same problem. my old func_lib have spawn actor from class. but i cannot make new func to spawn actor from class. cannot find that node anymore…

I ended up creating a macro in a macro library instead.

Same problem here in 4.11. There is no Spawn Actor node in Blueprint Function Library

Don’t take it as absolutely true, I may be wrong on this, but I’m pretty sure this isn’t a bug:

This might be because spawn node is somewhat latent… And functions can not be latent, they must end their functionality within the same tick… Besides, it needs to be sure the object you are calling the spawn from is on the level (actor) to spawn another actor. It takes the level in implicit reference.

But do not despair, one way around it is to implement a Spawn Actor event either on GameInstance or GameMode, and then call it on the FunctionLibrary, this way you can still spawn from function by delegating the spawn functionality to one of these sure-to-be-in-level classes

1 Like

Not sure if there is any other solution to this, but this is genius!

My setup(I left one temporary variable for future, to pass some extra info if needed as message to spawned actor):


While you can’t use Spawn Actor From Class inside a Function Library, what you can do is create the function inside your player character and then reference that function through your Function Library as a passthrough (IE create the same function inside your library and call the function on the player character to execute). The only advantage really is the quick accessibility of a Function Library. Otherwise, you can just call the function from your player character.