I’m trying to make a turnbased game, but having a bit of trouble with the visibility.
I want to be able to show a specific floor (and all below) and hide whats above.
Currently each floor is one big static mesh (build from instanced static mesh), so thats each enough to show and hide.
But there can be alot of actors at the diffrent floors, so keeping track of all, and do a show/hide of all gives the gave a hickup.
Currently I’m using the “Set Actor Hidden In Game” node to show/hide each actor (not sure if its the correct/best way to show/hide actors?)
I think you need to have all those meshes turned into actors, so no instanced meshes. Then make them check their location vs Z value you provide.
Second way would be using level streaming and loading/unloading.
And 3rd way (but i think you need masked materials for this, which may mess up lighting). Is making material that is aware of Z world coordinate, and make self masked out above that value.
However best method would be making something like limited voxel engine in C++. That creates voxels out of some data and cuts it all at Z value.
And yes there is reason that recent X-Com games had such terrible performance at release.
ps.
Look into dungeon architect, i did not used it for few years, and latest version may have implemented something for showing/hiding levels.
The “world mesh” (building, floor) is split up, so i have one for each floor. (this is the instanced mesh). This is quick to show/hide.
Its all the other actors that exists on the floor that i need to show/hide that are causing me trouble. (Including some niagara effects where i have to hide the component directly, even through actor is hidden)
Havnt looked into level steaming - i still need the actors to be there for detecting/shooting even through they are currectly hidden.
I think what I’m looking for is some sort of grouping of actors for show/hide.
Or if there is some other form of technic for this.
material that becomes transparent to hide all that.
Some tips for hide/unhide. I made asteroids game with thousands of objects and this is what i remember from my ideas:
do not do all that in single frame, make integer counter for every actor to be hidden, then hide every n-th one. You have about 20 frames to do so, it should be plenty.
make parent actor that has whole hide/unhide logic, then inherit it and set up visuals for them, dispatchers and that hiding only n-th actor should mask hickup enough.
hide/unhide only ones in view. Or keep them all hidden and show only those in view, this will minimize hickups on big maps
do whole processing if actors should be visible directly in them (in parent class). Like checking distance to camera, then checking if actor is in view, then checking if its on visible floor, etc
For big maps you can split map by sectors and floors, then process only parts in view. Again each parent actor should know their “sector” and check if they are in active sector.
For that material idea:
even invisible those meshes will still cast shadows. So if you want realistic style of game it is not for you
create master material, and then instanced material per sector. To hide/unhide change material to be visible only for active sectors. For that make material with transparency parameter. Then drive that from blueprints.
there may be way to make material be rendered only in range of from Z_low to Z_high range (world coordinate, mask only for Z value and drive transparency with that. Then you change Z_LOW and Z_hight from blueprints.