Download

Trouble using Add Child Actor Component to Create Random Tile-Based Maps on the Fly

Hello! Let me preface all this by saying I am a newbie here, so it’s very VERY possible I am missing something obvious. If I am, please inform me as nicely as possible.

Ok, I am trying to create a hexagon-based randomly generating map blueprint. The goal is to have 9 tiles randomly selected from an array of 18 possible and be randomly arranged and generated on the fly.

So far, I have made 3 different hex tile actor blueprints that have a static mesh base and differentiating markers on top. Each hex tile has 6 scene components with location transforms that mirror where a potential next tile would be placed to reference later.

https://forums.unrealengine.com/core/image/gif;base64

I have made a map generation blueprint that adds each hex tile to an array of actor objects, then starts a forloop equal to the size of the map (in tiles).

https://forums.unrealengine.com/core/image/gif;base64

Then I have two functions, one that randomly picks a tile from the array, and another that takes the selected tile and randomly selects a scene component (possible next tile spawn point).

https://forums.unrealengine.com/core/image/gif;base64

Finally, we reach my big problem. I now have the randomly selected tile from the array AND the transform for the next tile to be placed, BUT, how to I get the Add Child Actor Component to see which tile I have randomly selected and have that be the actor it adds?

433eba3b4414d9b63b7bb2aa4f0ef254.png

If anyone can help guide me here, or has any better ideas of ways to generate a map like this on the fly, your help would be IMMENSELY appreciated. Thank you!

Conner