2017-11-30 3 views
0

今私はボルトアクションシステムでライフルを作ろうとしていましたが、ボルトの回転をするのは本当に難しいので、回転動作を実装する方法が問題ですSteamVRのサーキュラードライブで使用されているようなものです。VRTKボルトアクションライフルにSteamVRサーキュラードライブを使用

私はVRの基本的なメカニックスを容易にするVRTKを使用していましたが、小さなもので問題を抱える剛体を使わずに1軸回転子を持たないようですオブジェクト(ボルトのようなもの)。

このビデオ(6時00分)に示したように、私は、SteamVRから円形ドライブのコンポーネントを使用することにより、ボルトの回転のための解決策を見つけた:https://youtu.be/r-edgGinqZ0?t=6m

しかし、それは文句を言わないそのコントローラーdosenとしてVRTKのために働きますサーキュラードライブが動作するために必要なSteamVRの(ハンド)コンポーネントを使用しないでください。

P.D:私はちょっと仕事しようとするスクリプトを持っていますが、意図していないよう:

if (isUising) //If the bolt is been used... 
    { 

     difference = Controller.transform.position - transform.position; //Make the vector diferentiate of the position of the controller and the bolt position 
     angle = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg; //Have the angle in radians of the Tan of the x and y of the vector diferentiate 
     angle = Mathf.Clamp(angle, 0, 65); //Clamp the angle to the max and minimum angles 

     rotFrame = angle * 6/65; //Transform the angle to frames for the animator 

     if (!boltOpen) //If bolt isint open/slided then: send rotFrame to the animator and check if the bolt is rotated to the open rotaiton or if its fully locked 
     { 

      BoltRotating(rotFrame); 

      if (angle >= 65) //If the angle is at the opened position, make the bolt ready for sliding 
      { 
       readyToOpen = true; 
      } 
      else 
      { 
       readyToOpen = false; 
      } 

      if (allOut) //If the bolt is closed reset the allOut bool to false 
      { 
       gun.Bolted(); 
       allOut = false; 
      } 
     } 



private void BoltRotating(float frame) //Activate rotation animation from the animator and play the animation with 0 speed and on the frame value from the angle 
    { 
     BoltAnimation.SetBool("Slide", false); 
     BoltAnimation.Play("BoltRotation", 0, frame); 
    } 

答えて

0

あなたはVRTKのための例のシーン021_Controller_GrabbingObjectsWithJointsで見たことがありますか? CircularDriveスクリプトの機能をValveから複製するホイールがあり、このスクリプトはVRTK_RotatorTrackGrabAttachと呼ばれています。その場面のホイールとドアには1つのものがあります。

hth。

J.

+0

ありがとうございました!私はVRTK_RotatorTrackGrabAttachを試しました。私のモデルでは、剛体を使用しているので、ボルトを壊したり、ライフルから取り出したり、別の場所に打ち上げられたように消えてしまう傾向があります。 – Hectorales

関連する問題