I am making a VR game and I decided that the game will use teleport locomotion.
The teleport on its own works fine but when I add it with the snap turning that I made I get a small offset from where I want to teleport to.
Here is the code that runs whenever I Teleport:
-- (TPSpot is the Position that i am teleporting to)
-- self.CameraCFrame is just the same as workspace.CurrentCamera.CFrame
-- self.UserCFrames is a table of all of the UserCFrames(Head, Floor and each Hand)
-- Headlock is on
self.CameraCFrame = CFrame.new(TPSpot-Vector3.new(0,self.UserCFrames.Floor.Y-self.UserCFrames.Head.Y,0)-self.UserCFrames.Head.Position)*self.CameraCFrame.Rotation
A few days late to your request but i might be able to help you.
Based on your code i wrote a few lines myself. I’m not able to test it since i don’t own a VR Set.
Let me know if it does or doesn’t work!
local destinationPosition = TPSpot - Vector3.new(0, self.UserCFrames.Floor.Y - self.UserCFrames.Head.Y, 0) - self.UserCFrames.Head.Position -- Calculating the position
self.CameraCFrame = CFrame.new(destinationPosition) * self.CameraCFrame.Rotation -- This is used for Teleportation
self.CameraCFrame = self.CameraCFrame * CFrame.Angles(0, math.rad(22.5 * -InputPos.X), 0) -- This is used for snapping
Unfortunately there is. I do know why this issue is occurring but i just dont know how to fix it. The reason it is teleporting when i turn is because of the offset between the cameraCFrame and the headCFrame making the head pivot around the cameraCFrame