Heya ,
An instance of the mesh in an Instanced Static Mesh Component can’t be directly accessed. And, while I haven’t looked at the code, I have a feeling the way performance is really saved is that it just adds all the meshes together and removes the reference (probably uses some sort of video card batching feature).
For the work I was doing I stored things in 2 ways:
-
During tile generation I just store everything in a number of arrays. Various ID’s define the tile type, facing, etc… just a simple int array. And then there’s the final grid array being the A* cost of the grid, which is updated during runtime as units move around or abilities that affect movement of the play area are used.
-
Since Instanced Static Mesh Components seem to strip out collision, I have a set of collision tiles. My collision tiles, wall or floor, hold all of the tile’s currently relevant information (3x3 neighbors, A* cost, tile type, material, trap data, parent room or corridor, etc…), and can be referenced by the unit currently standing on and can be clicked using the “Get Hit Result Under Cursor by Channel” node. There’s also an array of them that matches the A* grid for future use.
So the cost of non-rendering Box Component collision blueprint actors seems to be minimal, but I haven’t tried it with non-rendering static meshes (I’ll look into it tonight). Combined with the instanced static meshes for each tile mesh/material combo, keeps things running at a good clip. Tested on a 512x512 grid with no issues.
So getting to the “destroy/create” bit you were talking about… I’ve thought about this from the stand point of having a map editor. The best I could come up with, with the restriction of Blueprints, was to:
- Separate the play grid and the rendering grid.
- Have a function that would re-create rendering grid based on changes in the play grid
There’s a Clear function for the Instanced Static Mesh Component, and then I could re-generate a map based on changes to the generation arrays, but I have no idea how fast it would be. The hitch could be terrible…