VR hands being offset

I’m starting to develop with VR, and I’m currently working on the hands. Almost everything works, however when the player moves their head in their real playspace, the hands get more and more offset. I’m sure there’s an easy fix that I missed. Any help is appreciated, thanks! :3

	local LeftHandCFrame = game.VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
	local RightHandCFrame = game.VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
	
	VRFolder.LeftHandPosition.CFrame = (Camera.CFrame*CFrame.new(LeftHandCFrame.Position*HeadScale))*CFrame.fromEulerAnglesXYZ(LeftHandCFrame:ToEulerAnglesXYZ())
	VRFolder.RightHandPosition.CFrame = (Camera.CFrame*CFrame.new(RightHandCFrame.Position*HeadScale))*CFrame.fromEulerAnglesXYZ(RightHandCFrame:ToEulerAnglesXYZ())

1 Like

This was a code example from the documentation:

local VRService = game:GetService("VRService")

local part = workspace.Part

local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
-- Account for headscale
handOffset = handOffset.Rotation + handOffset.Position * workspace.CurrentCamera.HeadScale

part.CFrame = workspace.CurrentCamera.CFrame * handOffset

This didn’t seem to change anything when I tried it. Still gets offset. Any other ideas?

I can look into it tomorrow, if it hasn’t been resolved by then.

1 Like

Okay so I tried it and it worked perfectly fine. Here is the code I used:

local VRService = game:GetService("VRService")

local LeftHandPart = Instance.new("Part", script.Parent)
LeftHandPart.Name = "LeftHand"
LeftHandPart.CanCollide = false
LeftHandPart.Anchored = true
LeftHandPart.Size = Vector3.one * 0.25

local RightHandPart = Instance.new("Part", script.Parent)
RightHandPart.Name = "RightHand"
RightHandPart.CanCollide = false
RightHandPart.Anchored = true
RightHandPart.Size = Vector3.one * 0.25

game:GetService("RunService").RenderStepped:Connect(function()
	local LeftHandOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
	LeftHandOffset = LeftHandOffset.Rotation + LeftHandOffset.Position * workspace.CurrentCamera.HeadScale
	LeftHandPart.CFrame = workspace.CurrentCamera.CFrame * LeftHandOffset

	local RightHandOffset = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
	RightHandOffset = RightHandOffset.Rotation + RightHandOffset.Position * workspace.CurrentCamera.HeadScale
	RightHandPart.CFrame = workspace.CurrentCamera.CFrame * RightHandOffset
end)

And this was the result:

External Media

I’m not sure what exactly is happening on your part, but if I has to guess, I would assume it has something to do with the way you set the position of the hands. To vaguely describe it, it looks like it has been offset twice.

2 Likes

I tried swapping the cframing code in my script with yours and it works now! I’m not sure what the problem was in the beginning but thanks for the help :3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.