[Bug] Why does Spawn Actor error out when taking a class input?


I have tried working this from many angles. If you put an input on the Class input of SpawnActor this happens.

This happens when you reload the editor and the project. So I can plug my variable in, play it in the editor and everything works. If I close the editor and come back it errors out immediately.

I have tried various methods of input and setting the variable, but nothing works.

I even tried putting the class input on the outside of the function, leaving it set to Tile_Arctic on the outside, and running the line to the SpawnActor. It doesn’t care.

If I manually set this SpawnActor node to be Tile_Arctic it works perfectly fine and I can restart the editor as I like.

Did you happen to figure anything out with this bug? I have the same problem. Every time I reload my project, the SpawnActor node will fail to compile until I disconnect my class variable, manually select a class type in the dropdown and recompile (successfully, even if I choose the same class that was hooked up to it), and then reconnect my class variable. Then everything will work until I close and reopen the project. It’s easy enough to fix each time because I’m only doing this in one place, but it’s very annoying.

Nope. I just moved on and manually set the class on each spawn node.

I am surprised that more people haven’t run into this issue.

How about casting the returnvalue to the BP of the class you spawned?
Than you can get the Component. I’m spawning from an Array of Classes and never got that error. But im casting the result to a BPClass before using its components.

The screenshot works just fine when the Class input on Spawn Actor does not have a variable plugged into it.

Even if Cast magically fixes this issue, there is still a bug here.

I don’t know if that is really a bug.
Your manually set Actor got a Static Mesh Component, but a Variable that is set during the game could contain an Actor that doesn’t have that Component. So casting it would make sure that it has this Component.

It could be, that the Engine is exactly thinking like this. Or that i should go to bed :smiley:

Yeah but this isn’t an Actor variable problem it is a Class variable problem.

And this actually runs in game, until you either reload the editor or the dumb thing decides it doesn’t want to work anymore, whichever comes first.

:smiley: Ok. But since the error is at the return value of “Spawn Actor From Class” i thought i would more be a problem with the spawned actor not having a Static Mesh Component all time if you spawn from a class that doesnt have this component.

Guess i will watch this thread for a Staff answer (:

If you take the Class variable off, you manually set the Class. The same Class that is in the variable. And that works fine.

You get the same problem trying to pass a class in from outside of a function. Whether there is a variable on the outside or you manually set it, still the same problem.

It seems like you have to manually set the class on the spawn actor node or it throws fits.

If I set the class manually in the blueprint, it works; if I try to pass the class through a c++ function, then it doesn’t.