Пример #1
0
        private void InitHandle()
        {
            if (handles == null)
            {
                return;
            }

            if (handles.GetComponentInChildren <Collider>() == null)
            {
                VRTK_SharedMethods.CreateColliders(handles);
            }

            Rigidbody handleRigidbody = handles.GetComponent <Rigidbody>();

            if (handleRigidbody == null)
            {
                handleRigidbody = handles.AddComponent <Rigidbody>();
            }
            handleRigidbody.isKinematic = false;
            handleRigidbody.useGravity  = false;

            FixedJoint handleFixedJoint = handles.GetComponent <FixedJoint>();

            if (handleFixedJoint == null)
            {
                handleFixedJoint = handles.AddComponent <FixedJoint>();
                handleFixedJoint.connectedBody = doorRigidbody;
            }

            if (handleInteractableOnly)
            {
                CreateInteractableObject(handles);
            }
        }
Пример #2
0
        // Token: 0x0600140D RID: 5133 RVA: 0x0006F0C0 File Offset: 0x0006D2C0
        protected virtual void InitHandle()
        {
            if (this.handles == null)
            {
                return;
            }
            if (this.handles.GetComponentInChildren <Collider>() == null)
            {
                VRTK_SharedMethods.CreateColliders(this.handles);
            }
            Rigidbody rigidbody = this.handles.GetComponent <Rigidbody>();

            if (rigidbody == null)
            {
                rigidbody = this.handles.AddComponent <Rigidbody>();
            }
            rigidbody.isKinematic = false;
            rigidbody.useGravity  = false;
            if (this.handles.GetComponent <FixedJoint>() == null)
            {
                this.handles.AddComponent <FixedJoint>().connectedBody = this.doorRigidbody;
            }
            if (this.handleInteractableOnly)
            {
                this.CreateInteractableObject(this.handles);
            }
        }
Пример #3
0
        // Token: 0x0600140C RID: 5132 RVA: 0x0006EFD0 File Offset: 0x0006D1D0
        protected virtual void InitDoor()
        {
            GameObject gameObject = this.GetDoor();

            VRTK_SharedMethods.CreateColliders(gameObject);
            this.doorRigidbody = gameObject.GetComponent <Rigidbody>();
            if (this.doorRigidbody == null)
            {
                this.doorRigidbody             = gameObject.AddComponent <Rigidbody>();
                this.doorRigidbody.angularDrag = this.releasedFriction;
            }
            this.doorRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
            this.doorRigidbody.isKinematic            = false;
            this.doorHinge = gameObject.GetComponent <HingeJoint>();
            if (this.doorHinge == null)
            {
                this.doorHinge        = gameObject.AddComponent <HingeJoint>();
                this.doorHingeCreated = true;
            }
            this.doorHinge.connectedBody = this.frameRigidbody;
            this.doorSnapForce           = gameObject.GetComponent <ConstantForce>();
            if (this.doorSnapForce == null)
            {
                this.doorSnapForce         = gameObject.AddComponent <ConstantForce>();
                this.doorSnapForce.enabled = false;
                this.doorSnapForceCreated  = true;
            }
            if (!this.handleInteractableOnly)
            {
                this.CreateInteractableObject(gameObject);
            }
        }
Пример #4
0
        private void InitDoor()
        {
            VRTK_SharedMethods.CreateColliders(getDoor());

            doorRb = getDoor().GetComponent <Rigidbody>();
            if (doorRb == null)
            {
                doorRb             = getDoor().AddComponent <Rigidbody>();
                doorRb.angularDrag = DOOR_ANGULAR_DRAG;
            }
            doorRb.collisionDetectionMode = CollisionDetectionMode.Continuous; // otherwise door will not react to fast moving controller
            doorRb.isKinematic            = false;                             // in case nested door as already created this

            doorHj = getDoor().GetComponent <HingeJoint>();
            if (doorHj == null)
            {
                doorHj        = getDoor().AddComponent <HingeJoint>();
                doorHjCreated = true;
            }
            doorHj.connectedBody = frameRb;

            doorCf = getDoor().GetComponent <ConstantForce>();
            if (doorCf == null)
            {
                doorCf         = getDoor().AddComponent <ConstantForce>();
                doorCf.enabled = false;
                doorCfCreated  = true;
            }
        }
Пример #5
0
 // Token: 0x06001428 RID: 5160 RVA: 0x00070488 File Offset: 0x0006E688
 protected override void InitRequiredComponents()
 {
     if (base.GetComponentInChildren <Collider>() == null)
     {
         VRTK_SharedMethods.CreateColliders(base.gameObject);
     }
     this.InitRigidbody();
     this.InitInteractableObject();
     this.InitHingeJoint();
 }
Пример #6
0
        protected override void InitRequiredComponents()
        {
            if (GetComponentInChildren <Collider>() == null)
            {
                VRTK_SharedMethods.CreateColliders(gameObject);
            }

            rb = GetComponent <Rigidbody>();
            if (rb == null)
            {
                rb = gameObject.AddComponent <Rigidbody>();
                rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
                rb.angularDrag            = 30; // otherwise lever will continue to move too far on its own
            }
            rb.isKinematic = false;
            rb.useGravity  = false;

            io = GetComponent <VRTK_InteractableObject>();
            if (io == null)
            {
                io = gameObject.AddComponent <VRTK_InteractableObject>();
            }
            io.isGrabbable = true;
            io.grabAttachMechanicScript = gameObject.AddComponent <GrabAttachMechanics.VRTK_RotatorTrackGrabAttach>();
            io.grabAttachMechanicScript.precisionGrab = true;
            io.secondaryGrabActionScript = gameObject.AddComponent <SecondaryControllerGrabActions.VRTK_SwapControllerGrabAction>();
            io.stayGrabbedOnTeleport     = false;

            hj = GetComponent <HingeJoint>();
            if (hj == null)
            {
                hj        = gameObject.AddComponent <HingeJoint>();
                hjCreated = true;
            }

            if (connectedTo)
            {
                Rigidbody rb2 = connectedTo.GetComponent <Rigidbody>();
                if (rb2 == null)
                {
                    rb2 = connectedTo.AddComponent <Rigidbody>();
                }
                rb2.useGravity = false;
            }
        }
        protected virtual void InitDoor()
        {
            GameObject actualDoor = GetDoor();

            VRTK_SharedMethods.CreateColliders(actualDoor);

            doorRigidbody = actualDoor.GetComponent <Rigidbody>();
            if (doorRigidbody == null)
            {
                doorRigidbody             = actualDoor.AddComponent <Rigidbody>();
                doorRigidbody.angularDrag = releasedFriction;
            }
#if UNITY_2018_3_OR_NEWER
            doorRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative; // otherwise door will not react to fast moving controller
#else
            doorRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;     // otherwise door will not react to fast moving controller
#endif
            doorRigidbody.isKinematic = false;                                                   // in case nested door as already created this

            doorHinge = actualDoor.GetComponent <HingeJoint>();
            if (doorHinge == null)
            {
                doorHinge        = actualDoor.AddComponent <HingeJoint>();
                doorHingeCreated = true;
            }
            doorHinge.connectedBody = frameRigidbody;

            doorSnapForce = actualDoor.GetComponent <ConstantForce>();
            if (doorSnapForce == null)
            {
                doorSnapForce         = actualDoor.AddComponent <ConstantForce>();
                doorSnapForce.enabled = false;
                doorSnapForceCreated  = true;
            }

            if (!handleInteractableOnly)
            {
                CreateInteractableObject(actualDoor);
            }
        }
Пример #8
0
        private void InitHandle()
        {
            if (handles == null)
            {
                return;
            }

            if (handles.GetComponentInChildren <Collider>() == null)
            {
                VRTK_SharedMethods.CreateColliders(handles);
            }

            handleRb = handles.GetComponent <Rigidbody>();
            if (handleRb == null)
            {
                handleRb = handles.AddComponent <Rigidbody>();
            }
            handleRb.isKinematic = false;
            handleRb.useGravity  = false;

            handleFj = handles.GetComponent <FixedJoint>();
            if (handleFj == null)
            {
                handleFj = handles.AddComponent <FixedJoint>();
                handleFj.connectedBody = doorRb;
            }

            handleIo = handles.GetComponent <VRTK_InteractableObject>();
            if (handleIo == null)
            {
                handleIo = handles.AddComponent <VRTK_InteractableObject>();
            }
            handleIo.isGrabbable = true;
            handleIo.grabAttachMechanicScript = gameObject.AddComponent <GrabAttachMechanics.VRTK_TrackObjectGrabAttach>();
            handleIo.grabAttachMechanicScript.precisionGrab = true;
            handleIo.secondaryGrabActionScript = gameObject.AddComponent <SecondaryControllerGrabActions.VRTK_SwapControllerGrabAction>();
            handleIo.stayGrabbedOnTeleport     = false;
        }