Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Would I Determine The Y-Axis In A Placement System?

Asked by 1 year ago
Edited 1 year ago

Hello, I'm currently trying to make my own Stamper Tool, a problem I'm mainly having throughout making the models and parts snap to a grid is the Y Axis. The models and parts are in the ground. Here's the function I'm currently using to have the models and parts snap onto a grid.

local grid = 4
local function RoundToNearest(ToRound, Increment)
    return floor(ToRound / Increment + 0.5) * Increment
end

local function snap()
    local positon = mouse.Hit.p
    return CFrame.new(RoundToNearest(positon.X, grid), RoundToNearest(positon.Y, grid), RoundToNearest(positon.Z, grid))
end

My question is, how would I determine the Y-Axis of the model/part while also making sure you could build the models/parts upon each other.

1 answer

Log in to vote
1
Answered by
blowup999 659 Moderation Voter
1 year ago

Seems like the issue in the image is that the ground isn't at the same level as the grid, if you lower the ground it should work fine - You could also do RoundToNearest(position.Y, grid) + 2 or however deep it is in the ground there.

0
Thanks! Simply increasing the Y value by two worked, and everything else works. plooring 96 — 1y
Ad

Answer this question