so im making a grabbing system like in portal where you hover an object in front of you. but i wanted it to have physics so i unanchored it, and it started glitching out https://streamable.com/8f5d83
any way how to fix this?
here’s the local part
local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local mouse = plr:GetMouse()
local camera = game.Workspace.CurrentCamera
local holding = plr.Character:WaitForChild("Holding")
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E and not mouse.Target:IsA("Model") then
holding = plr.Character.Holding
holding.Value = mouse.Target.Name
game.ReplicatedStorage.Hold:FireServer(mouse.Target.Name)
end
end)
while true do
wait()
local exists = game.Workspace:FindFirstChild(holding.Value)
if exists then
local CameraLookVector = workspace.CurrentCamera.CFrame.LookVector * 10
exists.CFrame = CFrame.new(plr.Character.Head.Position) * CFrame.new(CameraLookVector.X,CameraLookVector.Y,CameraLookVector.Z)
end
end
and this is the serverside
game.ReplicatedStorage.Hold.OnServerEvent:Connect(function(plr,name)
local exists = game.Workspace:FindFirstChild(name)
local char = plr.Character
if char.Holding.Value ~= "" and exists then
char.Holding.Value = ""
exists.Anchored = false
exists:SetNetworkOwner(plr)
elseif char.Holding.Value == "" and exists then
if exists:FindFirstChild("CanGrab") then
char.Holding.Value = exists.Name
exists:SetNetworkOwner(plr)
end
end
end)
Maybe update the “exists” part CFrame with a RunService RenderStepped instead of a while loop to avoid the stuttering.
And maybe turning the part the player is holding to Massless = true could help
I guess you should anchor it while the player is holding it, and unanchor it when the player stops holding it if you want the part to fall after the player stop using it
In that case, I would try different approaches…
One could be moving the part with BodyMovers or Move Constraints, applying forces to the part to move it to the coordinate position the player is aiming the cursor. In that way it would hit against walls and ground.
Another one, could be raycasting to get the boudary limits in which the part can freely travel and where cannot
Ive heard bodymovers are deprecated now, and also i have a question, is there a doc page of the Move Constraints? i have searched it but i dont see it exactly
Yup, I heard that too, and I really like the body movers u ,u
Im not very used to the mover constraints, I just used them a couple of times, and well, does its job…
This is the first documentation I found about it in google: Mover Constraints
And I guess its better if you add them from Studio to check its behaviour and then search for documentation about each constraint
Maybe you only need to add one into your current system, to mantain the height level according to the player’s facing point.
Good luck! I like that system you are working on!
looked at the properties, seems its part-only, im trying to make it camera-relative and it seems theres no properties of that from my study of the docs
Nope, you can “feed” the forces used in all Mover Constraints with “world coordinates”, similar on how you are getting a world coordinate from your client facing point to place the part, that would make the part to travel where the player is facing, and collide against walls/parts (Im not saying its easy, surely that would take me days to achieve)
And remember raycasting is another tricky solution :3