-
Notifications
You must be signed in to change notification settings - Fork 67
Home
Welcome to the Godot XR Tools wiki!
This WIKI is now deprecated and will soon be removed.
You can find the most current documentation for Godot XR Tools here.
The Godot XR Tools library was created as a repository of classes to use when building an AR or 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 XR 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.
You will need to install the AR or VR plugin for your device which falls outside of this guide.
This add on should be installed in the addons/godot-xr-tools
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.
This library used to be called "Godot VR Common", we chose to rename it to make its purpose much clearer. If you used the old library make sure to rename the addons/vr-common
folder to addons/godot-xr-tools
before copying the new version in place. Renaming this within Godot will result in most references being updated automatically. Unfortunately this process is not watertight and you may need to do a search and replace with a multi file text editor tools like sublime
or atom
.
There is no code needed to initialize the add on.
Every Godot XR 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 XR 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 XR 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 and 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.
Originally this plugin was created with the player related physics objects assigned to layer #1. This caused a lot of issues for people who started using the plugin as it required moving all other objects to be moved into separate layers.
As of version 2.2 of the plugin all player physics objects are now placed in layer #20 and all the other default layer masks are setup such that other physics objects can remain in layer #1 and things should just work.
The physics layer system can be used to make your game run more efficiently especially when the number of objects increases.
Controller based features:
Helper scenes: