How to spawn actors from a Function Library?

SpawnActorFromClass cannot be used at all within function libraries or object classes. Not only does it fail to appear in search results, but it is not even permitted to be placed. It cannot be used even when WorldContextObject is provided as an input.

Instead, there’s a strange function called SpawnActorForGameplayTask. It seems this is not a replacement for SpawnActorFromClass. Is there any way to make SpawnActorFromClass work on an object?

objects can be provided world context in c++

if you’re stuck in blueprint i’d make a spawn manager, or even just gamemode/gamestate, you can use interfaces if you dont want hard refs.

honestly this is a better plan anyway because you should track the spawned actors somewhere too

that node is blocked in libraries on purpose since the backing spawn functions are marked internal only
add your own spawn function on an actor with a world context pin and call that from the library
pass the actor in and let it do the spawn so world context always resolves