Path Constraints Tutorial
This tutorial continues from the Getting Started tutorial. It is recommended you complete that one before starting this.
Path constraints are only available in Tessera Pro
So far we succeeded in generating a level composed of grass and path tiles:
However, for many purposes, a level like the above is not acceptable. If the player is only able to walk along the path, then it's not possible for the player to walk over all the path tiles of the map, there is simply no route between them.
So far, all our generation has been local - that is, we've controlled what tiles are placed next to each other, without any regard for the overall structure. Now we are going to use the PathConstraint to assert some global behaviour on the map. The path constraint can be used in various ways, this is only an introduction.
First select the generator object. Enable the
backtrack option. Backtracking makes the generator try harder to find a viable solution. It's necessary when using the path constraint as the generator can otherwise get stuck trying to find a valid path.
Next, add a
Path Constraint component to the generator. We need to configure the constraint, by telling it what we consider a path.
Recall that we colored the tile edge green if that edge was grassy, and brown if that edge had a path. We can give that information to the constraint.
Check the "Has Path Colors" checkbox, and then check the color corresponding to the path.
This tells the generator to search for all the sides of tiles that have that color in the center. If two such sides connect together, then it considers there is a path between those two tiles. The constaint then ensures that all path tiles connect to each other.
If we run the generator now, it'll only ever generate a single path:
Let's add the
tile_split tile to the generator, as you can get a lot more interesting paths once you allow junctions. The constraint will still ensure that it's always possible to walk accross the map.
tile_endRound to opposite corners of the generated area as a tile constraint. Because these tiles are also painted with the brown path color, they are considered part of the path. And because they are pre-placed, it forces the constraint to make sure both are connected.
A few last tweaks: Set the skybox to the
tile object to stop the path going off the edge of the map. And set the weight of the
tile object to 10, increasing the ratio of grass tiles to path tiles.
Now we have a generator that makes self-contained full navigable maps. Here's a few results.