I’ve been experimenting with a blocky placement system similar to Minecraft (and using textures of it) and I cannot get raycast to place blocks on the south, west, and bottom sides of existing blocks.
Its hard to explain whats going on here but here a video of it in action:
https://youtu.be/5mRubn0RUSA
I suspect its something to do with my rounding function but I cannot figure out which part of it makes it fail
function round4(num)
return math.floor(num / 4 + 0.5) * 4
end
but here’s the rest of my build function if it helps
local function build()
if buildMode then
--// Get mouse position
local mousePosition = UserInputService:GetMouseLocation()
local ray = require(script.CameraRay)(mousePosition.X, mousePosition.Y)
if ray then
if ray.Instance.Parent:FindFirstChild("Humanoid") then
return
end
local blockifiedPosition = currGhostBlock.PrimaryPart.Position
--// Get block and placd it at position
local block = BlockStorage.Placeable.Dirt:Clone()
block.PrimaryPart.Anchored = true
block.Parent = workspace
block.PrimaryPart.Position = blockifiedPosition
local weld = Instance.new("WeldConstraint")
weld.Parent = block
weld.Part0 = block.PrimaryPart
if typeof(ray.Instance) == "Model" then
weld.Part1 = ray.Instance.PrimaryPart
else
weld.Part1 = ray.Instance
end
block.PrimaryPart.Anchored = false
end
end
end