Skip to content
Bastiaan Olij edited this page Mar 26, 2020 · 11 revisions

Welcome to the Godot VR Common wiki!

Introduction

The Godot VR Common library was created as a repository of classes to use when building a VR game or experience using the Godot Game Engine.

The Godot Game Engines AR/VR system exposes a number of key nodes that allow you to create a VR game that in theory runs on any device. These nodes however do not implement any game logic leaving that up to the person implementing their game or experience. This library provides a number of example implementations that can either be used directly or used as inspiration to implement your own.

All examples found here make no assumptions of the hardware you are using. Obviously if you use something that requires positional tracking you need a 6DOF capable headset but other than that this toolkit attempts to be as agnostic as possible.

Some of the AR/VR plugins available do implement additional logic, OpenVR exposes render models, the Oculus Quest plugin has all sorts of neat helper objects, etc. This toolkit ignores those platform specific features but you are obviously free to mix and match. That is a big goal of the architecture.

Installation

You will need to install the VR plugin for your device which falls outside of this guide.

This add on should be installed in the addons/vr-common subfolder of your project. Note that the repository contains this folder and you should copy that folder over to your project. If you're downloading this add on from the asset library make sure to only add this subfolder to your project!

There is a project underway in Godot that will allow us to restructure this repository so the add on subfolder is the root of this repository which will allow you to submodule the add on.

Setup

There is no code needed to initialize the add on.

Every Godot VR project expects the following node tree in order to work:

We do assume here that we have controllers. If you are writing a 3DOF game or experience those are not needed.

Many of the VR plugins will have scenes that configure this for you but often with platform specific logic embedded. If you're creating a headset agnostic game setting this up yourself is advised.

You will also need to add some code to initialise the VR plugin. See the instructions for each plugins but it will follow this form:

func _ready():
	var interface = ARVRServer.find_interface("name of the plugin")
	if interface:
		if interface.initialize():
			# turn the main viewport into an ARVR viewport:
			get_viewport().arvr = true

			# turn off v-sync
			OS.vsync_enabled = false

			# put our physics in sync with our expected frame rate:
			Engine.iterations_per_second= 90

Finally you should add the addons/vr-common/misc/VR_Common_Shader_Cache.tscn subscene as a child of the ARVRCamera node:

This ensures the shaders that are used to render various parts of this toolkit are compiled when the game loads.

Features

Controller based features:

Clone this wiki locally