can you spawn actors and attach them to a component in the constructor script of an actor blueprint
when i try this in the actor blueprint constructor script spawning the actor fails and attaching it also fails
but when i do it after beginplay it seems to succeed
Hey @barbrian0723! I just took a look at this topic of yours as well, you shouldn’t be able to use the Spawn Actor node inside the construction script. In your update above did you mean you found a workaround for your objective? If so, that’s amazing to hear
I haven’t even tried that myself so wanned to see what happens, but I can’t even place the node in the construction script! By failing did you mean that or were you able to actually place the node? I wonder which version you’re on.
There should be no problem with attaching though. If you encounter any issues on that, you can share your blueprint code for us to take a look
initially i tried to spawn actors inside an actor blueprint as an easier why to construct a bigger actor
i tried this in the constructor script to be able to view as i construct
i used the spawn actor node and attach actor to component nodes with attaching the spawned actor to a scene component from / of the base actor blueprint
but the spawn actor node fails and return none. obviously the attach node will then also not work
i subsequently moved everything out to a function called by the begin play event
then spawn actor worked and also the attach actor to component node
i then switched to the add child actor node to spawn the actor instead, and then/ now i can spawn actors inside the constructor script as child actors
Why spawn actors on BeginPlay when you can pre-generate your map? Makes generation less debuggable and also adds another loading step after a map is started
Another use case is generating a level in the editor and then manually tweaking it. Doesn’t have to be in prod, there’s still a lot of benefit being able to do that during dev time
I know you can spawn actors in the editor in other ways. That’s also not straight-forward since the engine requires you to set some random ownership-related fields that you need to dig up from old forum threads