Ancestors Legacy

Ancestors Legacy

Not enough ratings
[MOD] Assets loading and the Tile System
By DC_vipeout
A little bit more advanced stuff, but still you will probably need that. How to load additional assets for your level and configure tiles to ensure proper NavMesh and terrain types handling
   
Award
Favorite
Favorited
Unfavorite
Assets loading
So, what assets loading is and why do you need to care? The basic idea is that you as a level creator have to guarantee that every asset you use on the level is loaded into memory. Otherwise, if the game code encounters an unloaded asset, the game will crash.

But why bother, why we do not load every asset on a game start? For performance reasons, the more assets to load the longer wait time for the game start. Also why we should occupy user's memory if we actually don't need it.

Okay, but why the game don't automatically detects what assets are needed for a specified level and load it? Well, it kinda do this, but this mechanics has its limitations. The good news is, all objects placed on the level are automatically loaded, so you don't have to worry about every single environment mesh for example. Bad news: it doesn't work for squad classes, because if you want to have a squad on your level you are not placing an actual squad actor, but Spawn Point (more info HERE). So you will have to manually take care about loading squads and every other actor, that you want to use (i.e. spawn from a Level Blueprint) and is not placed on a level.

Do you have to manually take care about loading every squad you use? Fortunately not. By having a Player Start on the level you are guaranteed to have every squad possible to recruit from this base loaded - so its nation dependent.

In short, you have to take care of loading those squads, that are not possible to recruit from any base on map - it's usually squads from a different nation than Player Starts and hero squads.


Example 1:
Player Start 1 - Slavs

Slavic infantry - Automatically loaded.
Slavic hero Mieszko - Need to be loaded.
German spearman - Need to be loaded.


Example 2:
Player Start 1 - Slavs
Player Start 2 - Vikings

Viking archers - Automatically loaded.
Slav cavalry - Automatically loaded.
Viking hero Ulf - Need to be loaded.
Slav hero Boleslav - Need to be loaded.
German crossbowman - Need to be loaded.


Additional classes to load

Now when you know which assets you need to load the question is how to load them. You have to open World Settings and in the Anc World Settings category use Additional Classes to Load.



Populate this array with entries referring to object classes you need to load. For squads use the same classes as in Spawn Points, so i.e. for loading Viking Archer squad class use BP_Anc_Squad_Vik_Archer class.
Tile System
Tile System is something we developed for Ancestors Legacy to improve game performance. It's not a place for digging into technical details, we'll just tell what you have to know about it as a level creator. Taking care of that may be burdensome, but it is required if you want to have fully correct level setup.

Each level's gameplay area is divided into small squares (tiles) and each of those tiles contains information about corresponding peace of land, such as terrain type, height, existence of NavMesh and more. Your job as a level creator is to ensure that those tile information are always up to date.

Generating tiles data is not a quick operation, it takes some time, so it is not performed automatically. You have to manually generate tiles after making significant changes to your level. Those changes can be:
  • Modifying level geometry in a way that affects NavMesh shape
  • Adding Player Starts, villages
  • Changing the layout of meshes indicating terrain type, i.e. removing rivers, adding forests
  • Changing the collisions on an object to or from "Landscape" preset - that's how system detects what counts as a floor to walk on

To update tiles info, select the BP_Anc_MapDesigner actor that should be present on your map after initial map setup (described HERE).



Then in the details panel find the Generate Regions button and click it (if you have multiple sublevels you have to make persistent level your current level before clicking the button).



Now you have to wait a couple of minutes, generation time depends mostly on how complex your level is and your CPU efficiency. Editor will be unresponsive for the time being, and at the end of generation process level will be automatically saved.


Terrain types

In Ancestors Legacy there are three special terrain types which have various effects on units:
  • Bushes - limited visibility, can't see what's inside from the outside of bushes
  • Forests - limited visibility, ranged defense boost
  • Water - limited movement speed

Note that terrain types can overlap, i.e. unit can be simultaneously in the forest and in the bushes. As you probably know, yellow icons on the left side of squad's banner tells you which terrain effects are currently applied.



At some point as a level creator you probably would like to put those special areas onto your level. It's quite simple. All you have to do is to place special meshes (linked to the specific terrain type) onto your level and generate tiles. Tile system will automatically calculate and remember special terrain areas based on meshes positions.

Here you can find references to those special meshes:
Blueprints/Game/TileMaps/BP_Anc_TileMap_Default'



So, to create forest/bush area just select a mesh from a corresponding category and place a few instances of it on level (near to each other).



It's a little bit more complicated if you want to create a water area - it is detected by the Tile System by material, not mesh. So, you can use a plane mesh (i.e. Environments/BaseMeshes_01/sm_en_sum_BasePlaneQuad_00100.) and apply the water material to create a water area. Place it in a suitable position (i.e. in a hole/crater/riverbed sculpted in landscape). You have to choose WaterPlane as Collision Preset for your water plane mesh!



After placing special terrain meshes all you need to do is to generate tiles - and Voila!


Debugging

If you want to verify your tiles setup there is a tool for it. Unfortunately it doesn't work in the editor viewport, you have to do this during gameplay (Play In Editor is supported). You will need to type console command (press ~ to open console):
con.ShowDebugTiles X
where X is number indicating a tool mode.

  • con.ShowDebugTiles 3

    Use this command to verify terrain types data. Debug widgets will appear near to you cursor and you can determine terrain types on corresponding tiles by widgets colors.



    White - No special terrain type
    Yellow - Bushes
    Green - Forest
    Blue - Water
    Red - More than one terrain type

    Usually it's easier to use this tool in wireframe mode (just press F1 during Play In Editor, F3 to return to standard mode)




  • con.ShowDebugTiles 2

    Use this command to verify NavMesh data on tiles. NavMesh tiles data should be synchronized with NavMesh, in other case you need to generate tiles again.




    You can look how an actual NavMesh looks like by using this command:
    show Navigation



    It's possible you will find yourself in a situation where tile height is not synchronized with level data. To deal with that you have to bare in mind that every surface which should be walkable for units should have Landscape collision preset. Of course after changing a collision preset you need to generate tiles.

  • con.ShowDebugTiles 0

    By using this command you can turn off tile visualisation tool.