2017-11-30 1 views
0

지금 볼트 작업 시스템으로 라이플을 만들려고했지만 볼트 회전을 만들기가 정말로 어려웠습니다. 그래서 회전 동작을 구현하는 방법이 있습니다. SteamVR의 순환 구동 장치에 사용 된 것과 같습니다.VRTK 볼트 액션 소총 용 SteamVR 순환 구동 장치 사용

유니티의 VR에 대한 연구를 시작한 이래로 나는 기본적인 기계공을 많이 사용하는 VRTK를 사용했지만, 리지드 바디를 사용하지 않고도 한 축 회전 장치가 없으므로 작은 문제 물체 (볼트와 같은). 이 비디오 (6시)에 나타낸 바와 같이

가 나는 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입니다. 그 장면의 휠과 문에 하나가 있습니다.

hth.

제이

+0

답변 해 주셔서 감사합니다! 그리고 네, VRTK_RotatorTrackGrabAttach를 시도했습니다. 그 모델은 rigidbody를 사용하기 때문에, 볼트를 부러 뜨리거나, 라이플을 꺼내거나, 다른 곳으로 발사되는 것처럼 사라지는 경향이 있습니다. – Hectorales