Advertisement Jump to content
Sign in to follow this  

How would I begin learning to build a sim based grid in Unity? (examples included)

This topic is 463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. If this topic is in the wrong section, I apologize. Mods, please move it so I know the appropriate category to put these questions in in the future. Or recommend better category to post questions like this one in so I'll know for next time.


I would like to experiment with building a sim type game. Can someone point me toward a resource that might help me understand how to lay out squares then allow the user to freely construct walls? Nothing beyond that for now, just an interface that places strait mono colored walls on a grid. 





Share this post

Link to post
Share on other sites

Those are not easy games to build, and the Unity engine is not designed to work like that out of the box.

Unity allows creation of arbitrary objects, and allows you to build and clone your own objects through a system of what they call "prefab" objects. Unity normally works with freeform placement, so all the work of creating wall-type objects, and the work of snapping objects to a regular grid, keeping that grid on the ground, and any other placement rules such as not interfering with other object's footprints would all be handled through your own game code.

I don't know of any specific versions, but I imagine the Unity store has several libraries that people have written for that type of thing. A few quick searches using Google show many tutorials and demos of working with grids generally, but I don't see any that cover exactly what you are looking for.

If you can find one of those as an existing tool on the store, that may save you some work.  You will probably need to modify it, tweak it around a bit, but it can give you a start.


As for what to learn if you intend to work like that,  the first thing you'll need is how to work with the math of the grid world.  If you aren't already comfortable with it, a grid can be put together fairly easy using modulus math (the % operator), but working at odd scales irregular placement outside the grid can be more tricky. 

Creating objects will mean understanding how to work with prefabs.  You'll want to read up on tutorials for creating prefabs and spawning prefabs through code. There are lots of tutorials on that.

As you'll want them on the ground layer, you'll want to find some tutorials about working with the ground. Many of the prefab tutorials have notes about using a raycast to find the height of the ground and then placing it at that height.  It can have trouble if your ground is not flat, so learning to modify your height grid programatically should be on your list if ground is not flat.  You'll note in the first two incarnations of The Sims players were forced to build a ground slab before placing walls.

After that, from your description you'll need to learn about rubber band selection or rectangle area selection so you can pick the items based on your mouse areas while playing in game. Again, there seem to be plenty of tutorials on that.

And assuming you want all this to happen in game as part of an in-game editor saving the world designs (rather than in the Unity editor where you modify your program's structure) you'll need to learn all about serialization or save/load systems.

If you are going for something like The Sims, that game does a tremendous amount of work to hide the differences between the logical world in data and the visual world that you see.  Game objects in logic are merged together. Many things are hidden in various ways. For example, you can only see inside the buildings on your lot, and only the height level you are currently on. When it comes to rendering many objects have their models and textures fused together so that instead of rendering hundreds of tiny decorations the game actually renders a few large irregularly-shaped objects. You generally don't see it as a player, and as a developer it is typically not seen unless working in the code directly related to editing the sims or editing the snap-together items in the world, such as countertops and walls.

I hope that gives you some options for places to look.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!