- What do you want to achieve? Keep it simple and clear!
Basically im making a placement system.
- What is the issue? Include screenshots / videos if possible!
I need the system to be able to stick to different surfaces if that makes any sense. Atm you can move the objects in a grid but you cant build on top of other blocks
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Some years ago when i didnt know about Object/World space i used to have this line of code in my systems:
local S = {
[Enum.NormalId.Top] = Vector3.new(0,1,0),
[Enum.NormalId.Bottom] = Vector3.new(0,-1,0),
[Enum.NormalId.Left] = Vector3.new(-1,0,0),
[Enum.NormalId.Right] = Vector3.new(1,0,0),
[Enum.NormalId.Front] = Vector3.new(0,0,1),
[Enum.NormalId.Back] = Vector3.new(0,0,-1)
}
local Surface = S[Mouse.TargetSurface]
CFrame.new(0,0,0) + (Surface * (Object.PrimaryPart.Size*.5))
I tried that with my new system which converts the Mouse position to object space. But it just doesnt work very well.
Anu help would be really cool since ive ran into a wall and dont know how to fix this issue.
Heres a vid showcasing the issue(As you can see from the video. I cant place cubes on different surfaces in this case the top)
And heres also the code i use in my placement system
local function Convert(CF,S)
return CFrame.new(
math.round(CF.X/3)*3,
S.Y/2,
math.round(CF.Z/3)*3
)
end
Mouse.Move:Connect(function()
if Mouse.Target ~= nil then
Mouse.TargetFilter = Object
local Rel = Plot.CFrame:ToObjectSpace(Mouse.Hit)
local Grid = Convert(Rel,Object.PrimaryPart.Size)
Object:PivotTo(Plot.CFrame:ToWorldSpace(Grid))
end
end)