Best way to handle 2D rpg-style "elevation" in grid graphs

Hello, I am working on a top-down rpg that has cliffs like so:

image

The characters should be able to stand on the left or right side of a cliff, but not cross over the edge.

I came up with a few ideas, but am not sure which is best (or even possible).

Is there a way to mark an edge as impassable?
Maybe I can use multiple grid graphs or a different graph type accomplish this?
I know I can increase the resolution of the graph, but that would decrease performance significantly, right? If so, I’d really prefer not to do this one.

Thanks ahead for the help.

Update
I looked into the Navmesh Graph, but am not quite sure how I am supposed to set this up for 2D. I might be totally wrong, but can I generate a mesh from the colliders and then set that as the source mesh?

Hey,

Depending on how you have the colliders set up, you might be able to just use the recast graph to scan this correctly.

Another possibility is to customize the scanning process of the grid graph, and manually control how connections between nodes are made, depending on the type of tile.

1 Like

My game uses tilemaps, sprites, and 2D colliders. Will that work with a recast graph? On scan, I got this warning: No MeshFilters were found contained in the layers specified by the 'mask' variables.

I think customizing the scanning process will work. I look into GridGenerator.cs and decided to make a custom class that extends GridGraph and overrides public virtual bool IsValidConnection (GridNodeBase node1, GridNodeBase node2).

Thanks so much for the help!

1 Like

Cool,

Good luck with the project.

1 Like