【问题标题】:VRTK Using SteamVR Circular Drive for a bolt action rifleVRTK 使用 SteamVR Circular Drive 制作栓动步枪
【发布时间】:2017-11-30 17:43:23
【问题描述】:

现在我一直在尝试制作带有螺栓动作系统的步枪,但是要使螺栓旋转真的很难,所以问题是如何实现像 SteamVR 循环驱动中使用的旋转动作。

自从我开始研究 Unity 的 VR 以来,我一直在使用 VRTK,它有助于许多基本的力学,但如果不使用 Rigidbody,它似乎没有单轴旋转器,这可能会遇到小物体的问题(就像一个螺栓)。

我通过使用 SteamVR 中的 Circular Drive 组件找到了螺栓旋转的解决方案,如视频所示 (6:00):https://youtu.be/r-edgGinqZ0?t=6m

但它不适用于 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);
    }

【问题讨论】:

    标签: c# unity3d virtual-reality vrtk


    【解决方案1】:

    您看过 VRTK 示例中的场景 021_Controller_GrabbingObjectsWithJoints 吗?有一个轮子应该复制 Valve 的 CircularDrive 脚本的功能,该脚本称为VRTK_RotatorTrackGrabAttach。在那个场景中,车轮和门上有一个。

    第一次。

    J.

    【讨论】:

    • 感谢您的回答!是的,我已经尝试过 VRTK_RotatorTrackGrabAttach,但我遇到的问题是,因为它使用刚体,在我的模型中,它往往会破坏螺栓,将其从步枪中取出或消失,就像被发射到另一个地方一样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多