I am trying to make arms in VR that interact with the environment using physics. The issue is the arms don’t stay aligned if you move around in the real world. I’m not sure how to fix this, as I’ve searched it up and none of the results helped.
The arms are interacting with the environment, and the attachments are where the hands are attempting to go. You can see where the controller is positioned, and they do not line up. I assume it has something to do with the camera, but I don’t know where to start.
Code below:
if VRService.VREnabled then
local moveHands = function(part, move)
if part == Enum.UserCFrame.LeftHand and checkHand("L") then
local alignPosition = Arms.handLeft:FindFirstChildOfClass("AlignPosition")
alignPosition.Position = (camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)).Position
local alignOrientation = Arms.handLeft:FindFirstChildOfClass("AlignOrientation")
alignOrientation.CFrame = (camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)) * CFrame.Angles(-90, 90, 0)
Arms.handLeft.Target.WorldCFrame = alignOrientation.CFrame
elseif part == Enum.UserCFrame.RightHand and checkHand("R") then
local alignPosition = Arms.handRight:FindFirstChildOfClass("AlignPosition")
alignPosition.Position = (camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand)).Position
local alignOrientation = Arms.handRight:FindFirstChildOfClass("AlignOrientation")
alignOrientation.CFrame = (camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand)) * CFrame.Angles(-90, 90, 0)
Arms.handRight.Target.WorldCFrame = alignOrientation.CFrame
end
end
VRService.UserCFrameChanged:Connect(moveHands)
end