User Input - ImmersiveStorytelling/DocumentationMasterclass GitHub Wiki

Eulerangles

These angles are actually the angles, the user is looking at.
When in a room, you could for example check wether the user is looking at the front wall, the left wall...
Then, you can use these inputs to change the room, music...

With the following code, you save the eulerAngles in the variable 'v'.
Vector3 v = GameObject.Find("Camera (eye)").transform.rotation.eulerAngles;
With v.x, v.y and v.z you can use the angles on each axis.


Controller input

With the following code, you can allow a user to make decisions through the touchpad of a controller.

device = SteamVR_Controller.Input((int)trackedObj.index);
if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
{
    Vector2 touchpad = (device.GetAxis(EVRButtonId.k_EButton_Axis0));
    if (touchpad.y > 0.7) { } //up
    if (touchpad.y < -0.7) { } //down
    if (touchpad.x > 0.7) { } //right
    if (touchpad.x < -0.7) { } //left
    if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad)) { } //release
}

Keyboard input

Keyboard input is the simplest input source of them all.
For example, if you want something to happen when the spacebar is pressed, you could use following code:

if (Input.GetKeyDown("space"))
{
    //action to be taken when spacebar pressed
}