Hey everyone! I'm excited to be getting back into game development after a one year break and working with PHP and web development.
I am restarting everything I was doing with a new sandbox tycoon game I've been working on over the past week, and progress has been going really well for how long I've been away from lua. Anyways, I've been facing a problem with the placement system in recent times.
Items are supposed to snap to the base in equal increments and are supposed to line up with the edge of a base.
It's very difficult to explain in text so here's an image of what happens, and what I need it to do:
(what happens) https://i.imgur.com/8CJ7U94.png
(what needs to happen) https://i.imgur.com/b7ZVqmT.png
The second picture shows the hitbox more clearly than the first one.
I have tried setting the CFrame to a proper position first before snapping to the players cursor, and yet it persisted to do the same thing.
This is what I have been doing for local player movement of an item (this is called on mouse.Move:
local function pos()
local primP = item2place.PrimaryPart
px = math.floor(mouse.Hit.X/size+0.5)*size
py = pl.Stats.LocalBase.Value.Base.Position.Y + primP.Size.Y/2 + pl.Stats.LocalBase.Value.Base.Size.Y/2
pz = math.floor(mouse.Hit.Z/size+0.5)*size
end
