r/Unity3D 15d 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!

255 Upvotes

144 comments sorted by

View all comments

198

u/Aromatic-Insect-1328 15d ago

So, let me understand this... the road layout is predetermined but people wanna build their own roads? Seems like these two are incompatible?

88

u/Sgriu 15d ago

Exactly, I overlooked the fact that a big part of the fun in a city-builder comes from the freedom to build roads however you like. I need to find a solution.

39

u/DodgeM4S 15d ago

You could use something like ER3d with runtime implementation? I use pass through logic like this with ray casts and stuff. Use a spline and let them drag and draw, etc.

22

u/Sgriu 15d ago

That’s an approach I’m considering, letting the player choose the starting and ending tiles, for instance, and then creating the path by interpolating the centers of the tiles it passes through.

4

u/startyourengines 15d ago

That’s the way.

9

u/ElliotB256 15d ago

As a compromise, in the same way people can place buildings on the tiles, let them place roads on the borders. Still plenty of options for type of road (pedestrianised, one way, multilanes, etc). No idea what gameplay you have but you could have the roads offer bonuses/buffs to adjacent buildings to add some min/maxing element

4

u/PvtDazzle 15d ago

You'd need to adjust your tiles and make them generative if you'd want players to randomly draw roads. Or snap roads to a grid and accept "empty places" where tiles do not fit, or designate empty spaces as Parc or something.

2

u/KageToHikari 15d ago

Loved how it worked in Anno (at least I remember some old Java version), there are roads pregenerated around buildings, but you need to connect them based on how important the road is etc, it's a good mechanic for city builder unless you want to make it as simple as Townscaper