Hey guys, how are all of you? I hope you are doing well. Alrighty so, today I started working on a placement system for my game and it works much better than my old one but that’s beside the point. The issue I am having with this system is with a specific rotation of the object, all of the other rotations work except for this one; see the video below:
Current code for this (ignore spaghetti code, going to rewrite later):
local isInsideHitbox = false
local axisisis = {"X","Z"}
local function PlotBounds(point)
local relativePoint = CFrame.new(Plot.CFrame:PointToObjectSpace(point))
local valid = {
X = false,
Y = false,
Z = false,
}
local X,Y,Z = hitbox.CFrame:ToEulerAnglesXYZ()
for _,axis in pairs(axisisis) do
local PlotSize = (Vector3.new(math.abs(Plot.Size.X), math.abs(Plot.Size.Y), math.abs(Plot.Size.Z)))/2
local modelSize = CFrame.fromEulerAnglesYXZ(X, Y, Z) * hitbox.Size
modelSize = Vector3.new(math.abs(math.round(modelSize.X)), math.abs(math.round(modelSize.Y)), math.abs(math.round(modelSize.Z)))/2
local ObjMin = hitbox.Position - modelSize
local ObjMax = hitbox.Position + modelSize
local BoundDistance = ((Plot.Size[axis]/2) - modelSize[axis])
--print(math.abs(relativePoint[axis]), ((Plot.Size[axis]/2) - modelSize[axis]))
if ObjMax.Y <= (Plot.Position.Y + PlotSize.Y) + 20 then
valid["Y"] = true
else valid["Y"] = false end
if math.abs(relativePoint[axis]) <= BoundDistance then
valid[axis] = true
else valid[axis] = false end
end
--print(valid["X"] , valid["Y"] , valid["Z"])
if valid["X"] and valid["Y"] and valid["Z"] then
isInsideHitbox = true
else
isInsideHitbox = false
end
end
If you have any questions please ask, I really don’t wanna go down the if statement fix route
Thanks guys!