I want to create a proper offset for my placing system so that an object is properly pushed out by a wall.
Example:
Here is the code for deterring a placed items position:
function Placeable.GetPlaceableSkeletonCFrame(raycastResult : RaycastResult, placeableObject : Model) local placeableBounds : BasePart = placeableObject.PrimaryPart local instance : BasePart = raycastResult.Instance local normal = raycastResult.Normal local position = raycastResult.Position local rayCFrame = CFrame.new(position) * instance:GetPivot().Rotation local offsetFromNormal = normal * placeableBounds.Size/2 local offsetFromInstance = instance.CFrame:ToObjectSpace(rayCFrame * CFrame.new(offsetFromNormal)) local y = offsetFromInstance.Position.Y local x = math.round(offsetFromInstance.Position.X) + math.fmod(placeableBounds.Size.X/2, 1) - math.fmod(instance.Size.X/2, 1) local z = math.round(offsetFromInstance.Position.Z) + math.fmod(placeableBounds.Size.Z/2, 1) - math.fmod(instance.Size.Z/2, 1) local placeableCFrame = CFrame.new(x, y, z) return instance.CFrame:ToWorldSpace(placeableCFrame) end As of right now this code only works for the offset of pushing a placed item off the ground, what would I need to add to compensate for walls?
