I want to make a turn-based strategy game based on a cube grid. The units should be placed on the grid in the editor before the game runs, so they can move in game similar to chess.
My “solution” was placing child actors in the grid manually, so I can set their attached unit in the editor but that is barely scalable.
The grid class adds child actor cubes based on grid size (x/y) and then i want to attach/assign a unit to the child actor component cube instance. If the cubes are generated only in construction, I can’t access them in the editor. How would you do this?
If you mark it as Instance Editable then it will be editable per instance for each tile, and it will appear in the editor when selecting a tile in your level.
Tried it now but I don’t think it’s what I need. When a block is on its own, so not in a grid, I can edit Unit in editor. When I create a block with the grid constructor, it shows in the viewport as child actors but not in the details panel. I can’t edit them.
I can also access and set the unit in the event graph/constructor with index but I was curious if there is an easier, faster way. For example making the blocks accessible in the editor.
Assuming central piece is in [0,0,0], and size of single cell is [wx,wy].
You can get current actor location. Substract central piece location. Then divide by wx.wy (trunc remainder). And you get cell coordinates.
You can (and should) make all pieces as separate actors, and each piece can calculate its own cell coordinates. Then piece sets its own coordinate, all can be done in constructor.
Imo. This is easiest way from coding pov. You just place pieces, snap to grid, they handle themselves.
Ps.
One of next steps will be creating map for those tiles. Keywords to feed google with are: “Wave function collapse”. And here is one of many vids from YT: