Position of part won't update to position of VR head position

I have been attempting to make a VR character but the head collider for the character won’t match its Y position with the VR head Y position. When I move my head set up and down, the part in game moves but much slower than the headset as if it has some down scaling to its movement.

This is in the local script and sets a bodyposition mover which is inside the head collider part to a certain y position above the root


game:GetService('RunService').RenderStepped:Connect(function()
    	local LC = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
    	local RC = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
    	local Head = VRService:GetUserCFrame(Enum.UserCFrame.Head)
    	print(Head)
    	
    	Part.Head.BodyPosition.Position = Vector3.new(Part.Head.BodyPosition.Position.X,(Part.LocoMotionBall.CFrame*CFrame.new(Head.p*HeadScale)).Position.Y+10,Part.Head.BodyPosition.Position.Z)
    	
    	
    	game.ReplicatedStorage.MoveClone:FireServer(ServerPart, Part.LocoMotionBall.Position, Part.Head.Position, Part.Head.Orientation)
    	
    	
    	
    	Cam.CFrame = Part.Head.CFrame
end)

it works perfectly fine before I move the headset up or down but when I do, the head collider moves very slowly up and down and doesnt align with the y position of the physical headset and I have no idea why it is doing this so any help would be appreciated.

Why not just weld to the head?
I haven’t dealt with VR before at all, so take this with a grain of salt.

I was about to say something about HeadScale, but it looks like you’re already correctly multiplying it, so instead, have you considered looking at this?
https://developer.roblox.com/en-us/api-reference/function/Camera/GetRenderCFrame
This will give you the exact CFrame the camera’s being rendered at.

Additionally, remove Cam.CFrame = Part.Head.CFrame. This is a bit hard to explain, but Roblox automatically offsets the camera by it’s own CFrame by a set amount when the VR user moves their head. You don’t need to update the CFrame to the new position of the part. This could be causing a chain reaction where when the part moves, the camera moves further.

Instead, if you intend on letting the VR user move in the world, update the CFrame to where the “base” position of the camera should be, and move your fake head part to where the camera actually is, using either GetRenderCFrame or multiplying GetUserCFrame by HeadScale.

You can’t weld anything to the head, as it doesn’t exist as a Part.

2 Likes

I figured out it wasn’t working because I had HeadLocked set to true but thanks for trying to help.