Developing HTC Vive--joystick Controls with Unity

Source: Internet
Author: User

The reason for writing this article is mainly because the virtual reality is very popular now, but the mainstream virtual reality device (HTC VIVE) Tutorial is less pitiful, this I have deep experience. therefore, I would like to develop in my usual problems and solutions to record down, share to everyone, if there is any mistake or what better plan we also please point out that we learn from each other, Haha.

okay, just on the Code.

Using unityengine;using System.collections;public class Shoubingkongzhi:monobehaviour {////////Ste    Amvr_trackedobject tracked;    void Awake () {//get handle tracked = Getcomponent<steamvr_trackedobject> (); }//Update is called once per frame void fixedupdate () {var device = steamvr_controller.input ((int.) track        ed.index); If (device.        Getpressdown (STEAMVR_CONTROLLER.BUTTONMASK.TOUCHPAD)) {Debug.Log ("press the disc"); } else if (device.        Getpressdown (SteamVR_Controller.ButtonMask.Trigger)) {Debug.Log ("press the trigger"); } else if (device.        Getpressdown (SteamVR_Controller.ButtonMask.Grip)) {Debug.Log ("press the handle side key"); } else if (device.        Getpressdown (SteamVR_Controller.ButtonMask.ApplicationMenu)) {Debug.Log ("press the handle menu key"); } else if (device.       Getpressdown (SteamVR_Controller.ButtonMask.ApplicationMenu)) {Debug.Log ("press the handle menu key"); }            }}

Debug.Log ("press the handle menu key");}}}
These are the key presses in the HTC Vive Handle. Others are:
Press the key to Release-device. Getpressup (SteamVR_Controller.ButtonMask.Trigger);
Press the key Changan-device. Getpress (SteamVR_Controller.ButtonMask.Trigger);
There is another way to press the button, but I feel very awkward with myself, not as good as the Above. Device. Gettouchdown (SteamVR_Controller.ButtonMask.ApplicationMenu);
Other usages are similar to Getpressdown ().

Reprinted from: http://www.52vr.com/article-391-1.html

Developing HTC Vive--joystick Controls with Unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.