How to make a Grid-Placement System? (CLOSED)

Yeah dont worry this is actually a very advanced topic, the link that pixel sent earlier to the tutorial is in my honest opinion way to complicated and just complicates everything;

With that being said… I have created this exact sort of system and it’s actually very well made; you’ve given me the idea to actually make it a module that people can actually use

5 Likes

Your talking about something like this right

6 Likes

Np, its nice to hear that i gave you a idea, and i also think that the link That pixel sent is very complicated
and yep im talking about something like the video u sent, and i really like the gui :+1:
(idk why but this might sound like that i want to have that exact thing, no it doesnt mean that, but well if u will of course allow me to use it i would, but this doesnt mean i want to, so like… yea i just thought that it kinda sounded like that i just wanted to say that its nice)

5 Likes

Thank you man means alot its from a project I was working on back in September but the scope was too large and I decided to abandon it but I still have the placement system, so im going too try to create a nice module that people can use to make it super easy to setup, thank you for giving my old project a purpose again

6 Likes

Np, i hope that you will find fun trying to make it so that it can easily help people like me, it would be nice if you could reply when you have a solution, have a great day/night/evening/afternoon and what ever time names there are.

6 Likes

Not sure if I can contribute a lot here, but you for starters need a snapping function.

local grid_size = 4

function snap(x)
 return math.floor((x / grid_size) + 0.5) * grid_size
end

function snapVector(v)
 return Vector3.new(snap(v.X), snap(v.Y), snap(v.Z))
end

It’s very short and simple but this should make sure positions are always rounded off and snapped to the specified grid size.

For collision detection you can either use Raycasts / Shapecasts or GetPartBoundsInBox().

5 Likes

do i have to change something? or add something?
cuz it doesnt really work, but still thanks for trying to help me

2 Likes

Yeah, these functions weren’t exactly intended to be directly copy-pasted.
But you can copy and change up things to adapt them to your code.

I usually just write my code snippets like that because I find it easier to show/explain things.

2 Likes

alright, thank you very much for trying to help me, sadly i only know 1% Lua Code, so… i cant really do much with the code that you gave me, but still thanks that you tryed to help me

2 Likes

I’m making impressive progress on the module!

Basically I’m porting alot of functions and stuff and just packing them into a seamless class that the server and client can use!

Current features:

Plot Claiming
Plot Rotation
Visualize Grid Points
Automatic Piece To Grid Dimensions
Grid Creation (specificed by gridSize)

3 Likes


This is the snapping used in my building game. My game also has relative grid so that’s what the relative position stuff is

But in a summarized way:
image
Position here is not a vector, you need to do the math for every axis. You can also have a different offset and grid size per axis
You’d also usually want the offset to be (by default) half of the grid size or the part size, or well, it will depend on the height of the surface you are building on, if the build system doesn’t use a relative grid

One other thing, you’ll have to play a bit with Mouse.Hit, to prevent the grid system from placing parts inside of the hovered part, basically rounding the wrong way

(Video of the issue I am talking about)

Here are the two “best” options (in my opinion)

– Make it so position is a bit before where the mouse ray collides with the hovered part

 -- This returns a CFrame 0.0001 studs closer to the camera
local TranslatedCFrame = Mouse.Hit * Vector3.new(0,0,0.0001)

Mouse.Hit points towards the camera (on the Z axis), which makes it very easy to translate

– Use the normal of the mouse hit to offset the position
This solution is quite good, as it’s perfect for making it so you can place parts on spheres or on top of wedges, while the previous solution works, it has the downside of allowing cubes to be placed diagonally to other cubes, which isn’t ideal
This is how it looks in my game


Here it returns a CFrame, but it should work just fine with a vector

What I mean by cube being placed diagonally

Hope this helps :wink:

2 Likes

I’d say you should definitely try familiarizing yourself with Luau a bit more before approaching something like a grid placement system. These types of systems are complex, and usually involve lots of advanced concepts such as object-oriented-programming. Try working on some smaller projects first, and work your way up to the big ones!

1 Like

I have made two resources that might help you make a placement system for your game:

  1. Placement Service
    I created Placement Service so it’s easy to make a grid placement system. The module is well documented and also has its own dev forum tutorial.

  2. My YouTube series on this
    I actually made a full series on making a placement system based on my module Placement Service. If learning how the system actually works is your thing, I explain everything you need to know to make a basic placement system from scratch!

2 Likes

that sounds very nice, and the Plot Claiming Feature will help me in the future too, i thank you very much for trying/helping me

1 Like

i know, the problem is i got no other ideas, and i find it kinda hard to learn Lua code, sadly the Offical Roblox Lua Code Guide book didnt helped that much, and another book i ordered to help me learn lua code turned out to be a fake book so a scam, in the future i will probably do other Methods to learn lua code, but currently i cant do much to learn it, still thanks for your respond

1 Like

Thank you very much, i will watch the video, and will read the Placement Service Post u made, thanks for your help!

1 Like

thank you very much, i cant really do anything with it cuz im not very good in programming yet, but still thanks for your help and it helps me a bit to understand lua code more, thank you very much

(also im sorry for the multiple replies in a row)

Yes!

I’m trying to make it as simple and seamless possible to set it up with no extra steps

More Features I’ve Created/ WIP :warning:

Datastore Integration

It will support plot saving for players right out of the box, and load them when you set a players plot, still working on like the actual saving buildins but the backbone of it is integrated into the placement system!

self:SetOwner(player : Player)

Basically this a function you’ll be able to call onto a new Placement class object, that will set the owner based on who the player has passed, and it’ll automatically check if the player has already claimed already aswell

Rotation and Dimension Flipping

When you rotate an object on the grid it won’t only rotate the currently piece your building with 90 degrees, but it will also flip the size dimensions relative to the grid; so you get some accurate nice rotation!

I’m starting to actually work on the client sided functions for building right now so things like, EnteringBuildMode, ExitingBuildMode, Rotating, ChangingBuildingPiece

Just some basic functions youll be able to pull from the module and use anywhere you would like to, were making great progress so far!

edit: Preview of the class rn Snappit - The pioneer for grid based plot placement systems (preview)

1 Like

Sounds very nice, can you maybe explain “Self:SetOwner(player : player)” a bit more? is it a command or a function in a script? just want to know
its nice to see that i gave you an idea, and i hope you are having fun to create it :slight_smile:

2 Likes

thank you very much for the help, however i have already seen the video before but got confused quickly, its a good tutorial but didnt really helped me much, still thanks for your help!

1 Like