Hey, how’s it going? Today I have an issue that I have not been able to solve for the past 3 days surprisingly and am running out of patience to solve it on my own and so now that we are all caught up lol here is my issue…
The goal to this is to add local part relative snapping with the object still being able to be reflected with the normal face of any object with even or odd whole numbers ( I can do that part) but the snapping as been an issue for parts other than the standard basepart.
Alrighty, now here is a video prieview of the grid snap video “working” and another video of it just reflecting off the normal face
Current code without implementation of grid:
local function RoundTo(n, to) local to = to or 1 if to == 0 then return n end return math.floor(n/to + 0.5) * to end local function SnapToGrid(vector3) return CFrame.new( RoundTo(vector3.X, GridSize), RoundTo(vector3.Y, GridSize), RoundTo(vector3.Z, GridSize) ) end function NearestAxis(Direction) local Axis = math.max(math.abs(Direction.X), math.abs(Direction.Y), math.abs(Direction.Z)) if Axis == Direction.X then return Enum.Axis.X elseif Axis == Direction.Y then return Enum.Axis.Y end return Enum.Axis.Z end function NormalOffset(NormalCFrame, Normal) local FilterAxis = Vector3.FromAxis(NearestAxis(Model.CFrame:VectorToObjectSpace(Normal))) local RelativeOffset = (Model.Size * FilterAxis).Magnitude * 0.5 return NormalCFrame + (Normal * RelativeOffset) end local function GetMousePlacementCFrame(HitNormal, Normal, HitCFrame, NewInstance) local RelativeOffset = NormalOffset(HitNormal, Normal) --local HitInstanceRelative = HitCFrame:ToObjectSpace(RelativeOffset) --local MouseHitWorldSnap = HitCFrame * SnapToGrid(HitInstanceRelative) --local HitInstanceRelative2 = HitNormal:ToObjectSpace(RelativeOffset) --local MouseHitWorldSnap2 = HitNormal * SnapToGrid(HitInstanceRelative2) local Combine = RelativeOffset --+ (MouseHitWorldSnap.Position - MouseHitWorldSnap2.Position) Model.CFrame = Combine * orientation end
I am nearing the end of ideas on how to solve this so if anyone could push me in the right direction or even supply a small example it would be very much appreciated, thank you.