Unity3d之HTC VR获取手柄的移动速度

 private SteamVR_Controller.Device hand;

public float speed=2;   //速度值随意设

     void Start(){

         var leftHands = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost);  //获得left手柄

         hand=SteamVR_Controller.Input(leftHands);

}

      void FixedUpdate(){

//方法一:

         if( hand.velocity.magnitude>speed){

               Debug.Log("手柄速度");

                 }

//方法二

          if(Vector3.Distance(hand.velocity,Vector3.zero)>speed){

              Debug.Log("手柄速度");

}

你可能感兴趣的:(Unity3d之HTC VR获取手柄的移动速度)