Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do people make 'tile' based tycoons/building in roblox?

I'm not sure how to explain it but when in these games you have a sort of building tool you can only place it in a specific way, like the ROBLOX stamper tool. Are there literally invisible tiles or is there some fancy math going on?

1 comment

0

They use modulo and math.floor ect to round to the nearest sqware giveing a grid like effect

1 answer

✓ Accepted answer

It's not magic

I just had to debunk that for you. You're welcome. What actually happens is that when they get your mouse hit position (mouse.Hit.p) they round off the X and Z axes. Here's an example implementation:

local function RoundTile(MousePosition, TileSize)
  -- I've been using js too much recently I just tried to use {} for the function body.
  local x,z = MousePostion.x, MousePosition.z
  x = math.floor(x/TileSize + 0.5)*TileSize
  z = math.floor(z/TileSize + 0.5)*TileSize
  return Vector3.new(x, MousePosition.y, z);
end;
  • MousePosition is the position that the Mouse is pointing at (Mouse.Hit.p)
  • TileSize is the size of every tile. Simples. squeak

This discussion is preserved as it was. New answers, comments, and votes are closed.