So I made a game with an isometric view (top-view,3d view) and I added a placement feature which should place structures. The object does follow the cursor however, It’s not in the right level of terrain.
Below is what I’m trying to show, The object follows the cursor where it should be placed and then upon clicking, the object should spawn there. I configured the code so that the structure will spawn on the right Y axis level, however, It’s too far on the cursor making it hard to see.
Code below,
local OBJRay,pos = workspace:FindPartOnRayWithIgnoreList(RayCast)
local ScreenRay = workspace.CurrentCamera:ScreenPointToRay(mouse.X,mouse.Y, 1)
local hitpos = ScreenRay.Origin + ScreenRay.Direction * 500
local newCFrame = CFrame.new(hitpos.X,1,hitpos.Z) -- This is the line that configures where the structure will spawn, as you can see, I made the Y axis 1 so it spawns just above the terrain, However It's too far from the cursor.
newStructurePlaceH:SetPrimaryPartCFrame(newCFrame)
end)
Second picture, This is what I’ve wanted to do, The object is just right near the cursor however, the object is not in the right axis and is too far from the ground.
local newCFrame = CFrame.new(hitpos.X,1,hitpos.Z) -- This is the line that configures where the structure will spawn, as you can see, I made the Y axis follow the Y axis of mouse however, the position of object is too far from the ground