Search Unity

How can I tell if Steam Controller is pointing down?

Discussion in 'AR/VR (XR) Discussion' started by GrumpyMouse, Feb 13, 2017.

  1. GrumpyMouse

    GrumpyMouse

    Joined:
    Jul 2, 2015
    Posts:
    5
    Hi,

    New to Unity and VR development, I am struggling to work out how to find out how the controller is pointing down (I want to mimic the reload type of Arizona Sunshine).

    I have looked at the device.transform and device.rotation and logged out the values but am struggling.

    Thanks in advance
     
  2. SuperScience

    SuperScience

    Joined:
    Feb 10, 2016
    Posts:
    17
    Hi GrumpyMouse!

    Here's how I would do it.
    1. Create a trigger collider box. Assign it to your VR headset. You can either have it a fixed distance from the VR headset in the Y direction, or you can set it to wherever the floor is under your player. (By default on Vive this is 0, but if you're moving your playarea around with some kind of "walk" or "teleport" controls, it could be different. You can raycast down if there's a collier on whatever surface the player is standing on)

    2. Raycast from the front of your controller.

    3. If it hits the box that should be at your player's feet, you know its pointing down.

    Out of curiosity, is this a Vive or Cardboard, etc?
    What are you using for handling the VR? SteamVR or something else?

    I can provide code examples if its similar to what I am doing. :)
     
  3. trd99

    trd99

    Joined:
    Dec 27, 2013
    Posts:
    13
    GrumpyMouse likes this.
  4. GrumpyMouse

    GrumpyMouse

    Joined:
    Jul 2, 2015
    Posts:
    5
    This is pretty much exactly what I ended up doing and adding a start and end number of degrees to treat as "down"