Unity3D (new) SteamVR 2.0 joystick input and vibration

Unity3D (new) SteamVR 2.0 joystick input and vibration

Recently busy two weeks, temporarily no time to get their project. OK, talk about my recent discovery of it.

VR company to do a shooting game, thought this was a simple task, before we know the results of the updated 2.0 SteamVR big change, it took some time to study, where to share research results.

First you have to configure the input SteamVR handle in the Window -> SteamVR Input configuration to the next, how to do this online tutorial, I will not elaborate.

Note, however, that, in the input set when the handle must ensure that your browser is normal , or will like me and C4 encountered embarrassing situation. . .

This is someone else's browser to open Effect:
This opens a browser effect for others
This is the C4's browser to open effect. . . :
This is the C4's browser to open effect.  .  .
But that's okay, if this happens can be applied in SteamVR selected equipment -> controller input setting sets the handle, but it is best to open the game set in the test , in order to see their own procedures to be set.

Then is Steam is the best online status , if only because Steam is online handle your settings will be saved.

Finally, talk about how to handle input and vibration call with the code:

 void Update()
    {
        //手柄输入:SteamVR_Actions.输入所在集_输入名称.检测方法(SteamVR_Input_Sources.位置)
        if (SteamVR_Actions.default_Fire.GetStateDown(SteamVR_Input_Sources.RightHand))
        {
        //手柄震动:SteamVR_Actions.default_Haptic.Execute(开始时间,持续时间,频率,振幅)
            SteamVR_Actions.default_Haptic.Execute(0, 0.2f, 5, 5, SteamVR_Input_Sources.RightHand);
        }
    }

Guess you like

Origin blog.csdn.net/qq_34229678/article/details/96970866