Hello,
I’m working on a VR project for testing and educational purposes. I’m guessing I have to use VRService.UserCFrameChanged
, but I’m not sure.
Does anyone know how to?
Hello,
I’m working on a VR project for testing and educational purposes. I’m guessing I have to use VRService.UserCFrameChanged
, but I’m not sure.
Does anyone know how to?
You are correct that you need to use VRService.UserCFrameChanged
however there are two parameters that are given in that event, the Enum value of the limb or head that was changed and the new CFrame value of it. Here is an example of how I handle VR movement.
VRService.UserCFrameChanged:Connect(function(Type ,new)
local vect = Vector3.new(new.X,new.Y,new.Z)
local camVec = Vector3.new(camera.CFrame.X,camera.CFrame.Y,camera.CFrame.Z)
if Type == Enum.UserCFrame.Head then
Head["BodyPosition"].Position = (CFrame.new(new.p*(camera.HeadScale-1))*new).Position
Head["BodyGyro"].CFrame = (CFrame.new(new.p*(camera.HeadScale-1))*new) * CFrame.Angles(0,0,0)
local CRX, CRY = Head.CFrame:ToOrientation()
elseif Type == Enum.UserCFrame.LeftHand then
LH["BodyPosition"].Position = camera.CFrame * (CFrame.new(new.p*(camera.HeadScale-1))*new).Position
LH["BodyGyro"].CFrame = camera.CFrame * (CFrame.new(new.p*(camera.HeadScale-1))*new) * CFrame.Angles(80,0,0)
elseif Type == Enum.UserCFrame.RightHand then
RH["BodyPosition"].Position = camera.CFrame * (CFrame.new(new.p*(camera.HeadScale-1))*new).Position
RH["BodyGyro"].CFrame = camera.CFrame * (CFrame.new(new.p*(camera.HeadScale-1))*new) * CFrame.Angles(80,0,0)
end
end)
I do not directly use the CFrame values, however they do translate to body force (this causes the vr parts to have their own physics instead of passing straight through blocks)
I have an open-sourced place that contains a lot of VR content. Check it out if you want.
Thank you for the help! Although I do have a question regarding your open-source VR game. It’s not uncopylocked, but it said that it was open-sourced. Is it supposed to be not uncopylocked?
It is now uncopylocked (I guess I ticked the wrong box)
Also be aware there may be a couple aspects that may not work fully as intended either because of Roblox updates or me fiddling with code.
Thanks for letting me know!