TileNodeNetwork
Last updated
Last updated
The TileNodeNetwork object type is used to define the walkable areas in a level. Once a TileNodeNetwork is created it can be used for pathfinding for AI-controlled entities such as Enemies.
The FlatRedBall Editor supports the creation and population of TileNodeNetworks. Typically TileNodeNetworks are filled using tile maps. This section covers common ways to fill a TileNodeNetwork. We recommend using the GameScreen and Level approach, as this makes it easier to maintain games with multiple levels. Using this pattern, a TileNodeNetwork would be defined in the GameScreen:
Select the GameScreen
Click Add Object to GameScreen in the Quick Actions tab
Select TileNodeNetwork as the type
Enter a name for your TileNodeNetwork such as WalkingNodeNetwork
Click OK
Be sure to create the TileNodeNetwork in the GameScreen so it is included in all levels.
TileNodeNetworks (just like normal NodeNetworks) must have nodes and links to be used for pathfinding. Each node represents a point on the map where an entity can walk. These nodes are connected by links which indicate how an entity can walk.
We can create nodes and links for each level from the tiles in our Tiled map. We have two options for doing this:
By indicating that all empty tiles in a map should contain nodes
By using a dedicated tile for marking where entities can walk
The first option is easier because it works for many simple maps without any modifications. The second option provides more flexibility.
For simplicity we'll use the first approach (empty tiles):
Select the new TileNodeNetwork
Click on the TileNodeNetwork Properties tab
Click the From Layer option under the Creation Options category
Select your map and the layer. Typically this is Map and GameplayPlay layer.
Verify the All Empty option is selected
Optionally you may want to make the TileNodeNetwork visible so you can verify that it has been filled in:
Select the TileNodeNetwork
Click the Variables tab
Check the Visible checkbox
The game should display the node network wherever no tiles are present.
Some games include specific tiles for pathfinding rather than all empty tiles. The first step is to determine which tile to use as walkable tiles. Whichever tile is used should have its Class (or Type if using older versions of Tiled) specified in the tileset in Tiled.
Once this tile Type is set (and the .tsx is saved), this tile can be used to mark walkable areas in the map.
To use these tiles:
Select the TileNodeNetwork
Click the TileNodeNetwork Properties tab
Check the From Type property
Select the Source TMX File (usually Map)
Select the type for the tile you just saved. It should appear in the drop-down if the .tsx file has been saved.
The TileNodeNetwork will now place a node wherever the walkable tiles are present.