Hello! I am trying to make a VR system for my game this is what I have so far
Here is the code
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")
local Character = script.Parent
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.HeadScale = 1.5
local LeftHand = Character:WaitForChild("Left Arm")
LeftHand.CanCollide = true
local RightHand = Character:WaitForChild("Right Arm")
RightHand.CanCollide = true
local DEFAULT_SPEED = 10
UserInputService.InputChanged:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
Character.Sphere.BodyVelocity.Velocity = ((Camera:GetRenderCFrame().RightVector * (input.Position.X * (DEFAULT_SPEED))) + (Camera:GetRenderCFrame().LookVector * (input.Position.Y * (DEFAULT_SPEED/0.75))))
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
Character.Sphere.BodyVelocity.Velocity = Vector3.zero
end
end)
RunService.RenderStepped:Connect(function()
Camera.CFrame = CFrame.new(Character.Sphere.Position) + Vector3.new(0, 7.5, 0)
Character.Sphere.BodyAngularVelocity.AngularVelocity = Vector3.zero
local LeftHandCFrame = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
LeftHand.AlignPosition.Position = Camera.CFrame.Position + LeftHandCFrame.Position * Camera.HeadScale
LeftHand.AlignOrientation.CFrame = Camera.CFrame * LeftHandCFrame
local RightHandCFrame = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
RightHand.AlignPosition.Position = Camera.CFrame.Position + RightHandCFrame.Position * Camera.HeadScale
RightHand.AlignOrientation.CFrame = Camera.CFrame * RightHandCFrame
end)
The thing is I want to make the ball move to the X and Z position of the players head but right now it’s just there. I want something like how Clashers Vr does
I am using a BodyVelocity to move the ball with the thumbstick and positioning the camera to the ball’s position plus a 7.5 stud offset.