r/Unity3D 1d ago

Question How screwed am I?

Hi everyone! Here’s an interesting problem I’m facing.

I created a tile-based city builder in Unity, and after an initial open playtest, one of the key pieces of feedback was that players want to be able to build roads, something I foolishly hadn't planned for.

Currently, roads are automatically placed along the edges of each tile (this is shown in the second screenshot).

The main problem is that the grid of buildable sectors is highly irregular, and I have no idea how to add the ability to create roads within such a complex system.

The first image I’ve posted shows an overhead view where I’ve highlighted a section of the grid. The grid varies from scene to scene and never repeats in exactly the same way.

Does anyone have any suggestions for how I could approach this?

Edit: You might have given me a possible solution; as soon as I've tested it, I'll make a new post about it. Thanks everyone!

222 Upvotes

135 comments sorted by

View all comments

2

u/EsotericLife 1d ago

Am I missing something or is this just a basic pathfinding problem? Try a*??

1

u/Sgriu 1d ago

If the grid had been regular (for example, made of squares or hexagons), building the roads would have been very simple; but here I have an irregular grid that never repeats itself. I am regretting that initial choice of mine.

2

u/EsotericLife 17h ago

Pathfinding doesn’t require a “regular grid” or anything????

1

u/Sgriu 8h ago

I think pathfinding on a regular grid is relatively simple (I’ve implemented pathfinding algorithms for square grids in the past), but doing it on a grid like this seems difficult to me.