Here are a few simple lines of code that will allow you to snap objects to a grid. [gridSize] must be defined beforehand and can be anything above 0, but values between 1 and 5 are recommended. [mousePos] can be any position vector (like a raycast position), but I am using mouse position for this example.

With this code, you can create an object at [GridPos] when mouse is clicked and it will be snapped to a grid.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.