Hello developers! I’m currently working on a VR Placement system like Nexus Vr, but with smooth walking instead of teleporting. I’m currently trying to replicate movement in the client with UserCFrameChanged, but I notice that the hands and head move a bit less than my actual hands and head. For this reason, I created a function to multiply the position value of a CFrame (CFramemult()), but I couldn’t find a correct value to multiply by. I also haven’t been able to move my virtual left hand. All 3 limbs are represented as 1 stud by 1 stud by 1 stud spheres. Here is my current script:
local vrs = game:GetService("VRService")
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
chr:WaitForChild("Animate"):Destroy()
chr:WaitForChild("Humanoid").Animator:Destroy()
local h = Instance.new("Part",workspace)
h.Shape = "Ball"
h.Size = Vector3.new(1,1,1)
h.Anchored = true
h.CanCollide = false
local rh = Instance.new("Part",workspace)
rh.Shape = "Ball"
rh.Size = Vector3.new(1,1,1)
rh.Anchored = true
rh.CanCollide = false
local lh = Instance.new("Part",workspace)
lh.Shape = "Ball"
lh.Size = Vector3.new(1,1,1)
lh.Anchored = true
lh.CanCollide = false
plr.CameraMinZoomDistance = 0.5
plr.CameraMaxZoomDistance = 0.5
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CameraSubject = h
local function CFramemult(cframe,value)
local t = {cframe:components()}
local s = {}
for i=1,#t do
if i <= 3 then
table.insert(s,i,t[i]*value)
else
table.insert(s,i,t[i])
end
end
local solution = CFrame.new(unpack(s))
return solution
end
vrs.UserCFrameChanged:Connect(function(typ, value)
local s,e pcall(function()
if typ.Name == "Head" then
h.CFrame = CFramemult(value,2) + chr.Head.Position
workspace.CurrentCamera.CFrame = h.CFrame
elseif typ.Name == "RightHand" then
rh.CFrame = CFramemult(value,2) + chr.Head.Position
elseif typ.Name == "LeftHand" then
lh.CRfame = CFramemult(value,2) + chr.Head.Position
end
end)
if not s then warn(e) end
end)
If anybody can help, that would be great. Thanks!