Controllers - RosoVRgarden/VRgarden-tutorials GitHub Wiki
There are many ways of doing interaction with objects and the easiest is through the Direct Interactor (hand) and the Interactable (object) through the event system (select, hover, …). Sometimes, you want to use the VR controller to do a specific interaction. It’s not recommended as it is confusing for the user who doesn't see the controller. The immersive interaction (diegetic) and the controller interaction (non diegetic - the controllers are not in the scene, they are outside) are not the same. However, for expert users using professional applications, it can be useful. Here are some information about the names of the controllers parts and how they can be used in Unity with minimal programming.
Input Feature |
Feature |
Vive |
Oculus |
Unity (default) |
|
|
|
|
|
trigger |
Button / Axis |
Trigger |
Trigger |
Activate |
grip |
Button / Axis |
Grip |
Grip |
Select |
|
|
|
|
|
primaryButton |
Button |
System button |
Primary (X/A) |
|
secondary Button |
Button |
n/a |
Alternative (Y/B) |
|
|
|
|
|
|
gripButton |
Button |
Grip Press |
Grip Press |
|
triggerButton |
Button |
Trigger Press |
Trigger Press |
|
|
|
|
|
|
primary2DAxisClick |
Button |
Trackpad-Press |
Joystick-Press |
Scale Toggle |
primary2DAxisTouch |
Axis |
Trackpad-Touch |
Joystick-Touch |
Move |
|
|
|
|
|
Note: I stands for XRI Interaction and L is stands for XRI Locomotion
Button action (true / false)
public InputActionReference toggleReference = null;
private void Awake(){
toggleReference.action.started += Toggle;
}
private void Toggle(InputAction.CallbackContext context){
action
}
public InputActionReference analogData = null;
void Update()
float value = analogData.action.ReadValue<float>();
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine. InputSystem;
public class ToggleObjectExample: MonoBehaviour
{
public InputActionReference toggleReference = null;
private void Awake(){
toggleReference.action.started += Toggle;
}
private void OnDestroy (){
toggleReference.action.started -= Toggle;
}
private void Toggle(InputAction.CallbackContext context) {
bool isActive = !gameObject.activeSelf;
gameObject.SetActive(isActive);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class ColorObject : MonoBehaviour
{
public InputActionReference colorReference = null;
private MeshRenderer meshRenderer = null;
void Awake()
{
meshRenderer = GetComponent<MeshRenderer>();
}
void Update()
{
float value = colorReference.action.ReadValue<float>();
UpdateColor(value);
}
void UpdateColor(float value)
{
meshRenderer.material.color = new Color(value, value, value);
}
}
Next to Color Reference or Toggle Reference, choose XRI LeftHand [RightHand] Interaction /Activate [Select] Value [Nothing]
By default Activate is the trigger (bottom) and Select is the grip button (side) but it can be changed.
Activate value and Select value gives more than true/false states, they give values. Here is a list of the all choices you have under Interaction. Scale Toggle, for example, is the primary2DAxis click.
Term |
Meaning |
Controller |
A component that turns XR controller input such as a button press into interaction events like hover, or select. Also provides a way to show controller models and send haptic feedback to the controller. |
Interactor (hands) |
An object in a scene that can select or move another object in that scene. See Direct / Ray Interactor. |
Interactable |
An object in a scene that the user can interact with (grab it, press it, or throw it). |
Hover |
The state where an Interactor is in a valid state to interact with an object. This differs between Ray and Direct interaction. |
Select |
The state where an Interactor is currently interacting with an object. |
Interaction Manager |
A manager component that handles interaction between a set of Interactors and Interactables. |
Gesture |
Sequences of movements that translate into an action that manipulates an interactable. |
Haptic |
Sensory or visual stimuli that is sent to the user to give feedback for interaction. |