im making a first person puzzle game where you need to pick up blocks, i have made a grab system but its just kinda bad the block jitters, doesnt have collision and it just doesnt work well heres a video of it : robloxapp-20221120-1033386
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")
local RunService = game:GetService("RunService")
focusing = ""
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E and mouse.Target then
holding = plr.Character.Holding
holding.Value = mouse.Target.Name
game.ReplicatedStorage.Hold:FireServer(mouse.Target.Name)
end
end)
RunService.RenderStepped:Connect(function()
wait()
local exists = game.Workspace.CanGrab:FindFirstChild(holding.Value)
if exists then
exists.Massless = true
local CameraLookVector = workspace.CurrentCamera.CFrame.LookVector * 10
exists.AssemblyLinearVelocity = Vector3.new(0,0,0)
exists.CFrame = CFrame.new(plr.Character.Head.Position) * CFrame.new(CameraLookVector.X,CameraLookVector.Y,CameraLookVector.Z)
end
end)
the serverside :
game.ReplicatedStorage.Hold.OnServerEvent:Connect(function(plr,name)
local exists = game.Workspace.CanGrab:FindFirstChild(name)
print(name)
local char = plr.Character
if char.Holding.Value ~= "" and exists then
char.Holding.Value = ""
exists.Massless = false
exists:SetNetworkOwner(game.Workspace)
elseif char.Holding.Value == "" and exists then
exists.Massless = true
char.Holding.Value = exists.Name
exists:SetNetworkOwner(plr)
end
end)
I remember you were working on this, its looking good!
Just a question, inside the RenderStepped that wait() is actually needed?
I would try to make less work inside the RenderStepped function that is updating the CFrame, I mean, letting the RenderStep to do less work so the update of the CFrame runs faster/smoother
Yup, we talked about that before, that the part will go thru walls, a solution a little dumb could be making the walls wider, the floor deeper, so the part wont have room to go thru…
Or maybe include raycasting to offset the CFrame of the part, if the raycast finds theres not enough space in front of the camera player, then use that hit position to offset the part backwards
Nope, tbh Im not the best in this topic, but, when I made a build system based on grid, no grid and some physics, using raycasting, reading normals, orientation for the part, offset, etc, I found that is pretty hard to achieve and took me a couple of weeks.
I cant be sure how you should offset the part if Im not working in your system, sorry I cant help with a line of code that fix it, its more like trial and error for me
@Katrist BodyMovers are deprecated, and using Mover Constraints is something I already suggested in another OP’s topic related with this same issue
You can just switch them out for their newer instances and it will work fine. It’s much easier than learning about raycasts from the start and thinking about the math.
Idk, that depends…
This is a project for a customer with a deadline? OP has a very important update in their game that cant wait and need any solution? Or this is for learning and improve skills and game…
Learning more useful stuff - VS - doing it in a different way
I still think that Movers Constraints (new bodyMovers) or raycasting, or even both could work together to achieve this project
i still need help tho, its not exactly what i want, and it wont work with my game, the part cant even go up for some reason, and even if i set the part to massless anything wont happen