VZController Interface

VZController is our low-level controller and VR interface abstraction. It also supports gamepad and keyboard control for testing when you don't have a bike or HMD.

It's loaded dynamically by VZPlayer, where it can be accessed as VZPlayer.Controller.

It's properties are

  • LeftButton - state of left handlebar button on bike, or VR hand-controller primary button with sensor
  • RightButton - state of right handlebar button on bike, VR hand-controller secondary button with sensor
  • DpadUp, DpadDown, DpadLeft, DpadRight - thumb buttons on left bike grip, or DS4 controller on PS4
  • RightUp, RightLeft, RightRight, RightDown - thumb buttons on right bike grip, or DS4 controller on PS4
  • InputSpeed - your pedaling speed in meters/sec (approximated at resistance setting 3)
  • HeadRot - yaw angle of your head in radians (positive counterclockwise)
  • HeadLean - amount you are leaning left/right in meters (positive left)
  • HeadBend - amount you are leaning foward/back in meters (positive forward)
  • Distance - virtual kilometers traveled this session (influenced by calibrated resistance)
  • Head - full transform of your head
  • IsSteamVR - using VIVE headset (on PC)
  • HasHmd() - using any VR headset
  • BatteryVolts() - voltage of bike or sensor (starts at 3, replace at 2.1)
  • HeartRate() - user heart rate on bike, or with S3 Watch on GearVR
  • UncalibratedResistance() - proportional to resistance setting on bike, needs app calibration

These functions describe the state of VZ bike or sensor connection

  • HasBikeDongle() - able to connect to bike or sensor
  • ReprogramProgress() - progress from 0.0 to 1.0 that bike firmware is updating, which happens before a connection
  • IsBikeConnected() - connected to bike or sensor
  • IsAlphaBike() - old VZ bike without directional buttons or reverse pedaling or resistance sensing
  • IsBetaBike() - currently shipping VZ bike
  • IsBikeSensor() - new VZ sensor (shipping in September)

The above buttons properties have these properties/methods

  • Down - true for every frame one's being held down
  • Pressed() - true for the frame a button goes down after being up
  • Released() - true for the frame a button goes up after being down
  • Held(float sec) - true for all the frames after a button has been held down for "sec"
  • Clear() - used to "clear" down button state to make Held() and Released() return false after it's been called

To get LeftButton and RightButton values with VZ Sensor, you need to use a hand controller that comes with your Rift (Touch), Vive, GearVR, or Daydream. Accessing these with Unity 5.4.2 requires that you separately install the SteamVR plugin, GoogleVR plugin, or OVR plugin for Unity, and enable the code in VZControllerMap.cs that talks to them (with the VZ_GAME build flag for all three, or by editing that file for just the plugins you install).  We'll soon add support for Unity 5.5+ to not require these plugin downloads.

You can test VZController functionality without a VZ bike or sensor when running from the Unity Editor with standard gamepads or keyboard, with the following mappings. Additional devices can be configured in Assets/VZ/Resources/VZControllerMap.xml

Gamepad

  • Left joystick - head lean and bend
  • Right joystick - head pitch and yaw
  • Left shoulder - left button
  • Right shoulder - right button
  • Left trigger - forward pedaling
  • Right trigger - reverse pedaling
  • Dpad and face buttons - same

Keyboard

  • WASD - head lean and bend
  • Arrows - head pitch and yaw
  • Enter - right button
  • Backspace - left button
  • Space - forward pedaling
  • Tab - reverse pedaling
  • IJKM - dpad on left bike grip
  • Keypad 8462 - ABXY on right bike grip