When placing actors in the editor, how do I automate randomly picking an actor variant from a set?

I have made several variations of a “wall” actor. I want to place a generic “wall” and have the editor randomly pick one of the variations. What is the best way to achieve this behavior?

I tried:

  • Making a blueprint to pick a random actor from an array and spawn it in the scene, issue is that it works only in play mode and I can’t actually design my level in the editor.

  • Creating a custom event and tick “run in editor” to fire the blueprint. Issue is that I have to manually click a button in the detail view for each actor, which is cumbersome.

  • Looking for ways to spawn actors in the constructor script, but no luck :confused:

I don’t need a complete solution. Any hint into what I should look into to achieve this would be appreciated.

Is this a randomly generated location maze like thing or simply a specific set of places you want these walls? Is each variant of the wall the same size model wise (assuming so but asking in case)?

When you say blueprint, do you mean the wall in question is the blueprint? If so opening it up and going to “viewport” will let you select a base mesh so you can see it in the editor. Afterwards in your event graph have an ‘on begin play’ event (or whenever you need to trigger this) “set mesh to X”

None of the above.

This is me literally dragging a wall from the content viewer into the scene. NOT in play mode. Straight up just within the editor. Don’t focus on the wall aspect or the features (IE maze or not), it’s just an example.

My issue is that I have 5 (visually) different variants of the same actor. Again, the number is just an example, I could have hundreds. When I drag and drop it into the scene IN THE EDITOR, I want the editor to randomly pick one, so that I don’t have to scroll through all my walls and decide which one I want.

I cannot use the “on begin play” event, as it only fires in play mode. I am never entering play mode. I am just designing my level in the editor and I’m too lazy to browse through the content, I want the engine to do it. Why is that so hard? :frowning:

EDIT: I tried to do something like this:


This is running on an editor utility actor. But it has issues.
1st. the editor immediately crashes when I try drag the actor into the scene.
2nd. the constructor script fires too often. Once when you drag it into the scene and then AGAIN when you let go of your mouse. I tried using the object guid to stop it from firing the 2nd time, but it seems the preview object and the final object are different instances with different guids so yeah, this approach won’t work, even if it didn’t crash lol

Figured it out. The Add Child Actor Component accomplishes what I needed. Blueprint ended up looking like so:

2 Likes