developing_for_oculus_quest.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. .. _doc_developing_for_oculus_quest:
  2. Developing for Oculus Quest
  3. ===========================
  4. Introduction
  5. ------------
  6. This tutorial goes over how to get started developing for the
  7. *Oculus Quest* with an official Godot plugin.
  8. Before starting, there are two things you need to do:
  9. First you need to go through the steps on the :ref:`doc_exporting_for_android`
  10. page. This leads you through installing the toolset that Godot
  11. needs to export to Android devices.
  12. Next you need the Quest plugin. You can get it from the Asset
  13. Library or manually download it from `here <https://github.com/GodotVR/godot-oculus-mobile-asset>`__.
  14. Setting Up Godot
  15. ----------------
  16. To get started open Godot and create a new project.
  17. .. image:: img/quest_new_project.png
  18. Make sure to choose the ``GLES2`` renderer. Due to the
  19. Quest's GPU this backend is far better suited for the Quest.
  20. Copy the addons folder from the Oculus Mobile asset into your Godot
  21. project. Your project tree should look similar to this:
  22. .. image:: img/quest_project_tree.png
  23. Now you can start building the main scene:
  24. - Add an :ref:`ARVROrigin <class_ARVROrigin>` node first.
  25. - Then add three child nodes to the origin node, one :ref:`ARVRCamera <class_ARVRCamera>` and two :ref:`ARVRController <class_ARVRController>` nodes.
  26. - Assign controller ID 1 to the first :ref:`ARVRController <class_ARVRController>` and rename that to ``LeftHand``.
  27. - Assign controller ID 2 to the second :ref:`ARVRController <class_ARVRController>` and rename that to ``RightHand``.
  28. - Finally add a :ref:`MeshInstance <class_MeshInstance>` as a child node to our first :ref:`ARVRController <class_ARVRController>` and create a box shape, resize the box so each side is set to 0.1. Now duplicate the :ref:`MeshInstance <class_MeshInstance>` and move it to the second :ref:`ARVRController <class_ARVRController>` node. These will stand in for our controllers.
  29. .. image:: img/quest_scene_tree.png
  30. Now add a script to the main node and add the following code:
  31. .. tabs::
  32. .. code-tab:: gdscript GDScript
  33. extends Spatial
  34. var perform_runtime_config = false
  35. onready var ovr_init_config = preload("res://addons/godot_ovrmobile/OvrInitConfig.gdns").new()
  36. onready var ovr_performance = preload("res://addons/godot_ovrmobile/OvrPerformance.gdns").new()
  37. func _ready():
  38. var interface = ARVRServer.find_interface("OVRMobile")
  39. if interface:
  40. ovr_init_config.set_render_target_size_multiplier(1)
  41. if interface.initialize():
  42. get_viewport().arvr = true
  43. func _process(_delta):
  44. if not perform_runtime_config:
  45. ovr_performance.set_clock_levels(1, 1)
  46. ovr_performance.set_extra_latency_mode(1)
  47. perform_runtime_config = true
  48. Before you can export this project to the Quest you need to do three
  49. more things.
  50. First go into the project settings and make sure that the main scene
  51. is the scene we run. Godot does not ask you to set this on export.
  52. .. image:: img/quest_project_settings.png
  53. Then go into the export menu and configure a new Android export. if
  54. you still haven't gone through the :ref:`doc_exporting_for_android`
  55. page do it now. If you didn't you'll have some red messages on this
  56. screen.
  57. If you did you can forge ahead and make a few small changes to the
  58. export settings. First change the XR Mode to ``Oculus Mobile VR``.
  59. Then change the Degrees of Freedom mode to ``6DOF``.
  60. .. image:: img/quest_export_settings.png
  61. Now save and close the export window.
  62. Setting Up Your Quest
  63. ---------------------
  64. Finally take out your phone, when you got your Quest you needed to
  65. install an Oculus app on it and link it up to your Quest. Start the
  66. Oculus app. Press the settings cogwheel on the bottom right hand side.
  67. Select your Quest:
  68. .. image:: img/quest_phone_settings.png
  69. Select "More Settings", and select "Developer Mode":
  70. .. image:: img/quest_phone_settings_2.png
  71. Now turn developer mode on:
  72. .. image:: img/quest_developer_mode.png
  73. This allows you to deploy your games to the Quest.
  74. Connect the Quest to your PC with the provided USB cable. Put the Quest
  75. on, it may give a few dialogs to give the PC permission to deploy apps.
  76. Now hit the little Android button that should be visible in the top right
  77. hand side of your Godot window. It should build your game and export it
  78. to the Quest.
  79. The above does the bare minimum to get your project running on the Quest,
  80. it's not very exciting. Holger Dammertz has made a great toolkit for the
  81. quest that contains a lot of scenes to get help you on your way including
  82. really nice controller meshes.
  83. You can find the toolkit `here <https://github.com/NeoSpark314/godot_oculus_quest_toolkit>`__.
  84. If you want to help out with improving the plugin please join us `here <https://github.com/GodotVR/godot_oculus_mobile>`__.