its a building system where u can build ahead, not a building system using mouse position so i need to check if there is a block infront of it so i can place a block +1 infront of it so i cant use mouse just a position in space
I don’t understand what you need the angle for. Can’t you just cast a ray in the downwards direction, from the X and Z positions of the block but with the Y axis of the root part?
For example,
for each block do
workspace:Raycast(Vector3.new(block.X, root.Y, block.Z), -CFrame.identity.UpVector * length)
i am trying to make a system where u can build ahead of your self so i need to check if there is a block already there so it can build 1 block ahead of that part
I think I understand, in that case couldn’t you just cast a ray every x studs defining an origin using the root’s look vector? It would likely be helpful if we had shaped raycasting (especially linecasting) but we don’t so the next best alternative would likely be to use a ray every x studs.
So for example:
for i = 1, numberOfRays do
local position = root.Position + root.LookVector * i * increment
local rayResult = workspace:Raycast(position, -CFrame.identity.LookVector * rayLength
if not rayResult then
there is no block here, place the block
break
end
end