I have a blueprint I call Spawners which is supposed to spawn enemies, the Spawners BP is tested and works. My map is randomly generated each game and I am trying to place the Spawners in my map using SpawnActor in my map BP but it won’t work.
I ran some tests using the event Q pressed in my character blueprint and the spawners worked perfectly. Then I copied and pasted the exact same code in my map BP and it no longer works.
Why is it that the return value is empty when this code is in my map BP?
Try running it after a short delay.
Adding a delay doesn’t make a difference.
Since you said it works in your character, but not when placed in map, I’m thinking that this is an input problem.
When you possess a Character it automatically captures your input, but if you have a BP in your level that you want to trigger with keypresses you’ll need to enable input on it: In BP Class Defaults set ‘Auto Receive Input’ from “Disabled” to “Player 0”
Me adding the Q button press was just a test. In the BPs construction script it runs another function which runs the PlaceSpawners function. Everything else in the construction script/event graph works, its just that dang spawn actors from class that doesn’t do anything.
I could see with some print strings that you were also right about that key press, but no matter how I call it that spawn actor still doesn’t do anything.
Hm, as a double-check: After you press play, you can press F8 and take a look at your outliner to see if any spawners have been spawned. (If they’re in-world but just not working maybe)
How are you testing this, what are you spawning, what’s in that actor? What are your expectations after spawning vs what happens?
Then I copied and pasted the exact same code
What code?
I have an actor blueprint in my scene called BP_MapMaker and in its construction script it runs all the functions to build the map and place the spawners. The Spawners blueprint is supposed to spawn a couple enemy units but I also put a large static mesh component in the blueprint itself just so I can see exactly to visualize where it is.
To test I just compile everything, hit the play button and run around a little bit. If the spawner is in game I should see that large static mesh but it’s never created, I even hit f8 and checked the outliner.
The nodes that I copied and pasted was what was in the picture. Spawn actor from class followed by a print string. It works when I connected it to the Q input in my character blueprint but it stops working in my mapmaker blueprint regardless of the Q input, no matter how it’s called it just doesn’t do anything in my mapmaker BP.
Actors placed in the world manually do not fire their Construction Script once the game begins, the Begin Play event is executed, though. Could this be the culprit?
Compiling the BP_MapMaker, updating it or simply moving it around the scene would fire its Construction Script (a lot!).
Well turns out the spawner did show up when I called it in a Begin Play event. I guess I’ll just have to keep it hooked up there although I don’t understand what difference that makes.
I could still see before that the Place Spawners event was running because the print strings were still working, for some reason the spawn actor from class just doesn’t do anything unless a begin play event calls it.
Glad to hear you have a solution.
Like ClockworkOcean mentioned, this might be a problem with timing then, other than that, since you’re randomly generating your map some dependencies might not be met at spawn time.
As for understanding what difference it makes, I’ll point you to this doc and this non-official video trip to the bottom of the rabbit hole.