Roblox has horrible documentation for the VR API, I just want to figure out how to get the CFrame of the controller, like the one that’s shown in the game. Everything I’ve done so far doesn’t seem to allow me to get the same position of the controllers in game.
This might be what you need?
Nope, that only gives me the position of the controllers relitive to 0,0,0
not the actual position of the controllers in the workspace.
Try this then
If you want the exact position where Roblox places the camera and controllers in VR you will have to look through the scripts they’ve made. As for VR in general, everything is based on an arbitrary offset, the only thing you can know for sure is where the controllers are relative to your headset (at least right now). You will have to place everything relative to the headset, and then move the headset with the character and so on.
Roblox doesn’t give the information you want. You have to do it relative to the head.
Don’t ask why. My guess is it’s how the Steam API works.
Other engines (UE4, Unity) have floor height api for every SteamVR and Oculus headset, so I’m assuming the API does exist. Roblox just doesn’t provide it on their end for some reason.
Hm, good point - I was referring to how the controller positions are locally relative to the headset
Hi, sorry for necro, but this is important code that everyone doing VR should know should know.
HeadScale = 1 Cam = workspace.CurrentCamera Cam.HeadScale = HeadScale local cfRH = VRService:GetUserCFrame(Enum.UserCFrame.RightHand) RightHand.CFrame = (Cam.CFrame*CFrame.new(cfRH.p*HeadScale))*CFrame.fromEulerAnglesXYZ(cfRH:ToEulerAnglesXYZ())
this gives full 3d tracking relative to the Headset.
the controllers are not positioned relative to the headset, they’re relative to the Camera CFrame.
refer to this diagram