Instancing tiles
The first thing we need in our game is a grid of hexagons to be used as tiled map for the ships movements. In my previous post I created a MainMap class, and here I'll put the code for the dynamic creation of our grid. Maybe you'll wonder why I didn't simply create an Actor instance for every tile in the map: the reason is that an Actor class is a bit heavy to handle for the Unreal Engine, so having hundreds of Actors in the scene only to render a static map isn't a good practice; especially when we have a nice and clean way to do it: components. An Actor can have many components, or sub-objects. They can be meshes, but also other types of sub-classes that handle a particular task for the main object (movement, aiming, etc.) This is the code to create a component from C++: With the CreateDefaultSubobject() method we can create a new empty component ( tile ) for our Actor. In order to make it visible, we have to assign it a StaticMesh. ...