Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would you guys go about making a vr game?

For Example. What kind of code would basically start it up and know when someone is in vr mode (if so does roblox provide that info?) and how would u make movable hands. Any help would be appreciated.

1 comment

0

I suggest you don't do VRService unless you're REALLY good at scripting. I suggest starting with smaller projects.

1 answer

VR is pretty difficult when it comes to scripting, there is little to no documentation on it and it generally requires knowledge of how VR works. But if you are willing to brave that then I could point you in the right direction.

#Basics

VRService is responsible for pretty much all the VR related stuff. Id recommend looking at its APIRefrence page, it contains pretty much everything you'll need.

local VRService = game:GetService("VRService")

#Detecting if VR is enabled.

This one is pretty simple:

if VRService.VREnabled then

#Movable hands

Roblox comes packaged with ingame controllers that follow your real controllers. If you want to replace them, then you will want to use SetCore and GetUserCFrame. You can use SetCore to remove the default controllers. GetUserCFrame returns the CFrame of a VR device in the game world, which VR device you want to get is specified by what you call it with. (Ex: Enum.UserCFrame.Head is the HMD, Enum.UserCFrame.LeftHand is the left controller, etc.). Use these together then you can replace the controllers.

local RunService = game:GetService("RunService")

local YourModel = workspace.YourModel

game.StarterGui:SetCore("VRLaserPointerMode", 0)

game.StarterGui:SetCore("VREnableControllerModels", false)

RunService.Heartbeat:Connect(function()
	YourModel.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
end)

#Input

VR input is still handled with UserInputService, so that should be familiar still. It functions the same as a console controller.

#Misc

This certainly isn't everything to know but I think its a good starter. Again I'd recommend looking at VRService's APIRefrence page.

This discussion is preserved as it was. New answers, comments, and votes are closed.