How do you code a proper VR game?

After reading up on the forum and reading about VRService, at least to me, it’s really unclear how to put everything together similarly to how this game is made. So how would I go about doing this? It would be great to see how all the VR elements are put together in code.

4 Likes

I am working on a VR module to make it very easy to make VR games so you can try checking that. Apart from just taking CFrame inputs and scaling / attaching things to them, that is really all there is to it.

I checked out this module a while ago and the documentation of it is very short. I was wondering if you could explain it more and how to properly set up.

I will update the documentation once I have time but most of it is explained within the example script. It provides you with some properties that are used to interface with the service in a more user-friendly and quick way.
You can do things like attach the player to a moving vehicle or put guns on their hands just by adding a couple of lines into the OnUpdate function (which runs every frame). It keeps track of the Height and Scale properties too even if you are upside down.

But where is the example script run? On the client? Are the hands controlled by the client?

Yes. That is basically the only way to be able to do it. You can sanity check the distance of their hands from their body but aside from that theres no telling a beatsaber professional from an exploiter

So where on the client would the example script be? Also just to clarify, I can just use VRService.VrEnabled to check if they are in VR and either make them a normal character or go into this VR mode?

Sure. In the future, my module will support neat features such as upper body IK for the head and hands so that you can be your roblox character in-game.

Upper body IK would be a really cool addition to the module, and I’ll probably be following it’s development. Though do you mind answering the question I asked about where the example script would be on the client?

1 Like

You can place it wherever you want it to be, as long as it runs.
In my case, the example script was placed in StarterCharacterScripts with a custom StarterCharacter to test.
Do note that I have yet to add an Init() function so it automatically attaches an OnUpdate handler when it is required.
Keep in mind that the CFrame data for the hands will be relative to VR.CFrame so you do not need to adjust them yourself if moving the player.
The inputs and button events etc. should be available in the Library as well. (Without needing to use UserInputService yourself)

2 Likes

Alright thanks for clearing everything up. Good luck on updating the module.

There has been added documentation hopefully clearing up how most of it works and how to use it