How to get actor visual before BeginPlay?

Don’t know how to call it right, so I will just describe what I want to achieve.

I have Pawn – BP_EnemyParty, it has array of BP_Enemy classes. When game starts it spawns enemy actors from this list and put them on positions. But in editor it looks like empty tile.

So my question: is there any way to run this code before game starts, so even in editor it would look like tile full of enemies?

Try using Construction Script in BP_EnemyParty for that exact purpose.


Have tried it, not working even when game starts. In BeginPlay same function works fine.

Unfortunately, without more elaborate description of steps or showing any code - it’s hard to guess what might not be working in there…

It’s really simple code, I just call Generate Party function in BeginPlay / Construction Script.

Here also Get Position just in case, but not much to look here at the moment.

Result, with function in BeginPlay:

It looks like your spawn box origin is exactly at the ground, which I guess will be the origin where the new character is supposed to spawn?
For characters, the origin is at the hip, perhaps the box is too close the ground and a newly spawned character would spawn halfway inside the floor, perhaps sometimes getting pushed through the floor.

Try moving the spawn box up by a good amount, so the spawned character can’t possibly collide with anything when spawning, but instead start in mid-air, and try again. At least that way you’ll know that spawn collision with the floor is not the issue.

You can also try changing the Collision Handling Override option in the SpawnActorNode to “Adjust If Possible But Always Spawn”, so if there is a collision at the original spawn location, the game will try to adjust it a bit.

Also, I don’t think it’s possible to spawn actors inside a construction script. If you try it anyway, either the game debug log should give you an angry message or just ignore your spawn attempt.


Seems like I have found “solution”, but it’s kinda… redundant, so I don’t know is it even Okay to use it.

I run in construction script Preview function to generate appearance in editor.

As I can’t do much with it further, I delete those children when game starts and re-generate actors.

It works…

Is it okay? Wouldn’t such approach be to heavy in terms of computing?

Oh, so if I understand you, you want to have a preview of what enemies will spawn depending on the character classes entered, but you don’t want these previews when playing the game, that’s why you destroy the previews, and for performance-reasons you don’t want to spawn the preview actors in the game?

You could try checking GetGameInstance in the preview function. If game instance is valid, you are in a game world (play-in-editor or standalone game), in which case you simply don’t spawn the preview child actor components at all.
You should then also be able to remove the for-each loop in BeginPlay, since you’d never spawn any preview child actor components in a game where BeginPlay is called.

If on the other hand GetGameInstance returns null, you are not in a game world, aka you are in some kind of editor, meaning you can create your child actor components for preview.

Can’t guarantee that it works, but you can try.

And as far as creating preview actors : It’s perfectly fine and common to have preview actors. In fact, all the actors you place in a level and see in your editor are also just “previews” and when you start the game in-editor, they all get duplicated into an entirely new game world.


Yeah, kinda. I want to see in editor what enemies I already put in world (white balls in case of spawning actors from code are not that informative :laughing:). When game starts and real actors are spawned there is just no need in previews further (guess destroying would free some resources).

I only today find out that I can Сast from Child and get access to actual Actor.
You guys are too polite, next time just bash me hard on my stupidity. :laughing:

Oh, don’t worry about being stupid, we all have these moments.

I’ve years of experience with Unreal C++ and sometimes i’m stuck for days because I forgot or messed up something trivial and obvious, but which I totally don’t recognize as an issue in the moment.

Glad you have fixed your issue :smiley: Never be afraid to ask if you are stuck.

1 Like