#Snap to grid building system

1 messages · Page 1 of 1 (latest)

coarse sorrel
#

So right now im making a roblox supermarket simulator and i want to make it so every plots cna buikd with a snap to grid build style like retail tycoon 2

fast trail
#

When you calculate the user's placement vector, cast it to the nearest vertex before attempting to place/render the object

sacred iris
fast trail
#

0 / 5 is 0. 0 * 5 is still zero.
1 / 5 floored is 0. 0 * 5 is still zero.

This continues onto 5 / 5.

5 / 5 is 1. 1 * 5 is five.
6 / 5 floored is 1. 1 * 5 is still five.

This continues onto 10 / 5.

10 / 5 is 2. 2 * 5 is ten.
11 / 5 floored is 2. 2 * 5 is still ten.

#

The grid must work in perfect intervals of GRID_SIZE. Floor-dividing a number by this interval tells us how many perfect vertices we can travel in that distance. We use this perfect vertex count to calculate the correct position at that distance from the origin

#

A given distance of 11.5 with a GRID_SIZE of 5 gives us 2 perfect vertices of 5 (5 fits into 11.5 2 times). This means we can travel 2 GRID_SIZEs from the origin, giving us a position of 10

fast trail
sacred iris
#

But it was not sarcarsm even if u had written it right i would still not know how to make a grid system

#

That was a genuine question

fast trail
#

I have a system on my GitHub that demonstrates the core logic behind a placement system:

#

This system is fully client-sided. It expects the client to click an eligible assembly to test placing it

#

You will have to modify this system for actual use in a project