PC Port - POINT-VR/POINT-VR-Chapter-1 GitHub Wiki

This will be a guide on how you can test any new features on your local set-up without a VR headset, using the current PC Port.

[!IMPORTANT] You should still test these features on a headset before merging to develop. This guide is primarily meant for preliminary testing before pushing your commit.

The PC Port is current still in development; if you notice any bugs, please join the Discord and write down the steps to reproduce the bug in #testing or in the "PC Port" thread in #action-items.

  1. PC Port Set-Up
  2. Running the PC Port
    1. Editor
    2. PC
  3. Controls
  4. For Programmers

PC Port Set-Up

  1. On GitHub Desktop, switch to the pc-port branch.

[!NOTE] pc-port will eventually be merged into develop once development is complete; in the meantime, it is on its own branch but can still be used for local testing.

 

  1. Go to Branch → New branch... and create a new branch based on pc-port (not develop).

 

  1. Open Unity Hub and the POINT-VR-Chapter-1 project as usual.

Running the PC Port

[!NOTE] The PC port relies on mapping existing inputs from VR controllers to keyboard and mouse. Therefore, if the feature you are developing requires modifying the Controls.inputactions file, PC port may not work. If so, testing on a physical headset will likely be required. Afterwards, please post in the "PC Port" thread on Discord so that one of the developers can work on adding the new mapping to the PC port.

Editor

  1. From the scene that you are testing, press the Play button. You can now test the simulation using the PC Port controls!

 

[!NOTE] When running in the editor, the cursor will be visible; this is not the case when the application is properly built and run on a PC.

PC

  1. Go to File → Build Settings... and switch the platform to "PC, Mac & Linux Standalone". Press "Build" and select the Builds/PC_Port_Builds folder.

 

  1. Once the build files have been generated, in your File Manager, go to Builds/PC_Port_Builds/ and click on Einstein's Spacetime. The PC port should run now as an application for testing!

[!WARNING] For now, please avoid committing any files that have been modified/generated from the building of the PC port, unless otherwise asked to.

Controls

  • Move: WASD
  • Teleport + Interact: Left click
  • Grab: Right click (Hold) or C
  • Push: R
  • Pull: F
  • Pause: Esc
  • Look around: Mouse

For Programmers

The rest of this page will discuss the programmatic implementation of the PC port. To summarize, most of the implementation is based on a set of PC control bindings as well as the use of Platform Dependent Compilations in C# scripts.

[!NOTE] Currently, the conditional compilation used is #if UNITY_STANDALONE_WIN || UNITY_EDITOR for a Windows PC and the Unity Editor respectively. For compatibility with MacOS, Unix, etc., this will likely have to be changed to include those platforms as well.

PCPortManager.cs

  • Path: Assets/POINT/InputAssets/PCPortManager.cs
  • Attached to: Player prefab

This script handles almost all variables and changes that happen when switching from VR to the PC port:

  • UI adjustments (e.g. menu position offset, subtitle height, etc.)
  • Player movement (e.g. walk speed)
  • Appearance of crosshair
  • Deactivation of VR-specific elements (e.g. haptics, appearance of hands, etc.)

Its Start and Update functions will compile only on specific platforms. Start enacts the required changes, whereas Update handles player movement. Helper functions allow for adjusting the appearance of the crosshair.

PauseController.cs

  • Path: Assets/POINT/InputAssets/PauseController.cs
  • Attached to: Player prefab

Platform dependent compilation is used for the following changes to pausing in PC port:

  • Cursor is unlocked and visible (to allow for interaction with UI with a visible mouse cursor)
  • Crosshair visibility toggles on (when unpaused) and off (when paused)
  • The reset position of the UI menu when unpausing

XRHardwareController.cs

  • Path: Assets/POINT/InputAssets/XRHardwareController.cs
  • Attached to: Main Camera (VR, PC), Left Hand (VR only), Right Hand (VR only)

In the PC port, this script controls the camera movement (i.e. looking around) when the simulation is unpaused.

HandController.cs

  • Path: Assets/POINT/InputAssets/HandController.cs
  • Attached to: Left Hand (VR only), Right Hand (VR, PC)

[!NOTE] The right hand is active but not visible in the PC port, achieved through disabling its MeshRenderer in PCPortManager.cs. This ensures that there is an active instance of HandController.cs in the scene.

This script controls all hand controller inputs (e.g. Pause, Grab, Interact, etc.). For the PC port, the following changes are made:

  • All Raycasts originate from the Camera (using ScreenPointToRay) instead of from the hand
  • The crosshair changes color instead of the laser from the hand
  • The velocity of a mass (upon released/thrown) is calculated based on its change in position, as opposed to the velocity of the VR controller