How would I make gridded movement like in Miner's Haven? In the game, I can select an item from my inventory and the item will snap to the grid when I move the mouse over it but will not move outside of the grid.
What systems will I need to make and how will I go about using them
This can be achieved using the Hit
property of the PlayerMouse
instance which can be retrieved using the :GetMouse()
method of the LocalPlayer. To grid the position, you will need to math.floor()
the x
, y
and z
of the Hit. Then just repeatedly CFrame a part to the floored hit. The below code will create a grid on the CFrame.
local m = game:GetService("Players").LocalPlayer:GetMouse() local h = m.Hit local gridCFrame = CFrame.new(h.x, h.y, h.z)
I hope my answer solved your problem! If it did please remember to mark it as correct! :)