Okay, I actually have two questions. I’m working on a picking up and holding system, but I want it to work in first person and third person, so I want to know how I can Raycast from the camera rather than the mouse, so it will work in both. I’m having trouble implementing this. Another question, how would I stop the parts from spazzing like crazy? In the video I attached it spazzed out a bit, I’m not sure how to stop it. If anyone could help me with these problems that would be nice.
And my current Raycast code (If someone can show me how to use WorldRoot:Raycast() that would be cool!)
function RaycastFromMouse(Range)
local RayIgnoreList = {Player.Character or nil}
for i,v in pairs(PartIgnoreList:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") then
table.insert(RayIgnoreList,v)
end
end
local mouseRay = Mouse.UnitRay
local newRay = Ray.new(mouseRay.Origin,mouseRay.Direction.Unit * Range)
local target,pos,norm = workspace:FindPartOnRayWithIgnoreList(newRay,RayIgnoreList)
return {target,pos,norm}
end
Is there a way that I can prevent WorldRoot:Raycast() from returning the endpoint of the ray as nil? I would like to be able to find the Vector3 of the endpoint even if the ray does not end on a part.
At one point, while it was spazzing, I printed out the RotVelocity of the part and it was not Vector3.new(0,0,0). I’m curious as to what causes it to change, as Roblox says it is deprecated which makes me think they would not have physics change that value. None of my scripts change the value either.
The part is not anchored, I want physics to interact with it. Instead, I added a BodyForce that takes into account the gravity in workspace and the parts mass to cause it not to fall.
The current system uses WorldRoot:FindPartOnRayWithIgnoreList() I will migrate it over to WorldRoot:Raycast(). Can you give me an example of good RaycastParams for this scenario?
Now they can go through the floor when I’m holding them. The part is anchored now. Do you know why this is? It does not do it when the part is unanchored.
I was still reading the code, but since you editted I couldnt continue. First thing I noticed is you dont need the task.wait on the end of the event. Secondly, are you changing each part relatively? You would be better off making it a model and then having the player only move the PrimaryPart while the other parts would be welded to this one.
That is what I did for the crate model, and I added the crate model into a folder in workspace that is the ignore list for the ray. Then I welded one part in the folder HoldParts to the crate model.