Help with Graph Generation for Disjointed Islands in a 2D Game

I’m currently developing a 2D game in Unity that features a dynamically generated map with distinctive terrain types: islands (land) and water. The terrain generation is based on a Perlin noise algorithm, resulting in multiple disjointed islands amidst water. Additionally, the terrain differentiation is visually supported by two extra textures (with configurable alpha and rgb values) serving as masks/colliders for Land and Water, designating walkable and non-walkable areas.

My primary concern involves setting up pathfinding in this varied terrain environment. Specifically, while attempting to utilize a RecastGraph to accommodate the game’s non-grid-based, free movement:

Water areas, being large and contiguous, work well with RecastGraphs using colliders to mark non-walkable areas.
Islands, comprising disconnected entities, pose challenges. The pathfinding graph does not generate effectively around these smaller, scattered landmasses using similar collider-based approaches.

Using a GridGraph and setting a TileRule with a Texture works, however, the game is NOT based on a grid, nor is the movement.

How could I handle this use case? Thank you very much!

Hi

Do you have a screenshot of this? In particular the part where you don’t think the navmesh is being generated well.

Hello Aron, thank you so much for your reply! I’ve attached the colliders I use for rasterizing the graph. I recently changed the game’s PPU so everything is bigger now, and I see that it now generates the mesh for some ground areas (it didn’t detect anything before), it seems it was the graph’s configuration that maybe didn’t detect walkable areas. Considering this just to clear the doubt, the Graph can detect colliders like the WaterCollider correctly, right? According to this test, it seems to work properly!




Indeed. In 2D it can in fact only use colliders.

The main parameters you may want to tweak is the cell size (essentially the resolution it rasterizes the world with), and the Character Radius (you may want to reduce this a bit for your world, but in that case you probably also want to reduce the cell sie).

1 Like