I’ve been trying to create a object grab and placement system similar to the one in SCP-3008, I was able to create target detection, hold trigger, and highlighting (outline), however one big issue I’ve encountered is trying to position the object.
I do not know how, I’ve already tried searching the Developer Forum however none of the posts that came up on the search was the behavior I desire, and adding on the fact that I lack knowledge on using CFrames makes this more difficult.
I’m not really asking for you to provide code, I’m just asking, how should I achieve this?
If you want to know what I currently have for the movement, it’s this but as you can see it’s definitely not similar to the one in SCP-3008 and it’s stuck on one axis (I believe?)
local function TranslateMousePosTo3dSpace(blacklist: {BasePart}, directionMultiplier: number?)
local MouseRay = workspace.CurrentCamera:ViewportPointToRay(Mouse.X, Mouse.Y)
local MouseRaycastParam = RaycastParams.new()
MouseRaycastParam.FilterType = Enum.RaycastFilterType.Blacklist
MouseRaycastParam.FilterDescendantsInstances = blacklist
return workspace:Raycast(MouseRay.Origin, MouseRay.Direction * (directionMultiplier or 1000), MouseRaycastParam)
end
--// CurrentTarget = The current object being held (can be a model or part)
--// CurrentTargetBlacklist = Table with target part(s)
local RaycastResult = TranslateMousePosTo3dSpace(CurrentTargetBlacklist, 2000)
if (not RaycastResult) then return end
CurrentTarget:PivotTo(CFrame.new(Vector3.new(RaycastResult.Position.X, RaycastResult.Position.Y, RaycastResult.Position.Z)))
As for the distance limit, I figured I could do something like this, now I just need to make the part align to the surface while aligned to the mouse aswell, anyone got a good idea on how to do this?