How would I do a system like Minecraft block facing?

In Minecraft you can place a Block and the Block will face towards you. I already have a building system done, and a partially working system of the later using lookAt and a lookVector. But I can’t figure out how to limit the Rotation to straight degrees, like 90 etc. How would I go along accomplishing this and is it easy? Is stuff like Orientation in degrees or radians?

You can get the Y axis rotation of the camera and then snap it to 90 degrees and turn it into a CFrame, here’s the code for that

local _, Y, _ = workspace.CurrentCamera.CFrame:ToOrientation()
local Rotation = CFrame.fromOrientation(0, math.round(Y / math.rad(90) - 2) * math.rad(90), 0)

You can then add the position of the block to the CFrame to combine the rotation with the position

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.