protected override void InitRequiredComponents() { if (GetComponentInChildren <Collider>() == null) { Utilities.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.precisionSnap = true; io.stayGrabbedOnTeleport = false; io.grabAttachMechanic = VRTK_InteractableObject.GrabAttachType.Track_Object; hj = GetComponent <HingeJoint>(); if (hj == null) { hj = gameObject.AddComponent <HingeJoint>(); hjCreated = true; } }
private void InitDoor() { Utilities.CreateColliders(getDoor()); doorRb = getDoor().GetComponent <Rigidbody>(); if (doorRb == null) { doorRb = getDoor().AddComponent <Rigidbody>(); doorRb.angularDrag = 10; doorRb.collisionDetectionMode = CollisionDetectionMode.Continuous; // otherwise door will not react to fast moving controller } 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; } }
private void InitDoor() { Utilities.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; } }
private void InitHandle() { if (handles == null) { return; } if (handles.GetComponentInChildren <Collider>() == null) { Utilities.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.precisionSnap = true; handleIo.stayGrabbedOnTeleport = false; handleIo.grabAttachMechanic = VRTK_InteractableObject.GrabAttachType.Track_Object; }