protected virtual void SetControllerAttachPoint() { //If no attach point has been specified then just use the tip of the controller if (controllerReference.model != null && originalControllerAttachPoint == null) { //attempt to find the attach point on the controller SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject); string elementPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, handType); Transform defaultAttachPoint = controllerReference.model.transform.Find(elementPath); if (defaultAttachPoint != null) { controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { Rigidbody autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } } else if (originalControllerAttachPoint == null) { Debug.LogWarning("Grabbing object is missing an attach point; one will be auto-generated"); controllerAttachPoint = GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { Rigidbody autoGenRB = gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } }
/// <summary> /// The PopulateHighlighters method sets up the highlighters on the controller model. /// </summary> public virtual void PopulateHighlighters() { if (actualController != null) { highlighterOptions.Clear(); VRTK_SharedMethods.AddDictionaryValue(highlighterOptions, "resetMainTexture", true, true); autoHighlighter = false; baseHighlighter = GetValidHighlighter(); if (baseHighlighter == null) { autoHighlighter = true; baseHighlighter = actualController.AddComponent <VRTK_MaterialColorSwapHighlighter>(); } SDK_BaseController.ControllerHand currentHand = VRTK_DeviceFinder.GetControllerHand(actualController); baseHighlighter.Initialise(null, actualController, highlighterOptions); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonOne, currentHand)), baseHighlighter, elementHighlighterOverrides.buttonOne); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonTwo, currentHand)), baseHighlighter, elementHighlighterOverrides.buttonTwo); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Body, currentHand)), baseHighlighter, elementHighlighterOverrides.body); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripLeft, currentHand)), baseHighlighter, elementHighlighterOverrides.gripLeft); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripRight, currentHand)), baseHighlighter, elementHighlighterOverrides.gripRight); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.StartMenu, currentHand)), baseHighlighter, elementHighlighterOverrides.startMenu); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.SystemMenu, currentHand)), baseHighlighter, elementHighlighterOverrides.systemMenu); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Touchpad, currentHand)), baseHighlighter, elementHighlighterOverrides.touchpad); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.TouchpadTwo, currentHand)), baseHighlighter, elementHighlighterOverrides.touchpadTwo); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Trigger, currentHand)), baseHighlighter, elementHighlighterOverrides.trigger); } }
protected virtual string GetElementPath(string currentPath, SDK_BaseController.ControllerElements elementType) { SDK_BaseController.ControllerHand currentHand = VRTK_DeviceFinder.GetControllerHand(actualController); string foundElementPath = VRTK_SDK_Bridge.GetControllerElementPath(elementType, currentHand); return(currentPath.Trim() == "" && foundElementPath != null ? foundElementPath : currentPath.Trim()); }
protected virtual void CreateTouchCollider() { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); Object defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand)); if (customColliderContainer == null) { if (defaultColliderPrefab == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "default collider prefab", "Controller SDK")); return; } controllerCollisionDetector = Instantiate(defaultColliderPrefab, transform.position, transform.rotation) as GameObject; controllerCollisionDetector.transform.SetParent(transform); controllerCollisionDetector.transform.localScale = transform.localScale; controllerCollisionDetector.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Controller", "CollidersContainer"); destroyColliderOnDisable = true; } else { if (CustomRigidBodyIsChild()) { controllerCollisionDetector = customColliderContainer; destroyColliderOnDisable = false; } else { controllerCollisionDetector = Instantiate(customColliderContainer, transform.position, transform.rotation) as GameObject; controllerCollisionDetector.transform.SetParent(transform); controllerCollisionDetector.transform.localScale = transform.localScale; destroyColliderOnDisable = true; } } controllerCollisionDetector.AddComponent <VRTK_PlayerObject>().objectType = VRTK_PlayerObject.ObjectTypes.Collider; }
protected virtual void Awake() { destroyColliderOnDisable = false; var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand)); }
private void Awake() { cachedElements = new Dictionary <string, Transform>(); var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); if (modelElementPaths.bodyModelPath.Trim() == "") { modelElementPaths.bodyModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.Body, controllerHand); } if (modelElementPaths.triggerModelPath.Trim() == "") { modelElementPaths.triggerModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.Trigger, controllerHand); } if (modelElementPaths.leftGripModelPath.Trim() == "") { modelElementPaths.leftGripModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.GripLeft, controllerHand); } if (modelElementPaths.rightGripModelPath.Trim() == "") { modelElementPaths.rightGripModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.GripRight, controllerHand); } if (modelElementPaths.touchpadModelPath.Trim() == "") { modelElementPaths.touchpadModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.Touchpad, controllerHand); } if (modelElementPaths.appMenuModelPath.Trim() == "") { modelElementPaths.appMenuModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.ApplicationMenu, controllerHand); } if (modelElementPaths.systemMenuModelPath.Trim() == "") { modelElementPaths.systemMenuModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.SystemMenu, controllerHand); } }
// Token: 0x06001597 RID: 5527 RVA: 0x0007693C File Offset: 0x00074B3C protected virtual void SetControllerAttachPoint() { if (this.controllerReference.model != null && this.originalControllerAttachPoint == null) { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(this.interactTouch.gameObject); string controllerElementPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, controllerHand, false); this.attemptSetCurrentControllerAttachPoint = base.StartCoroutine(this.SetCurrentControllerAttachPoint(controllerElementPath, 10, 0.1f)); } }
private void Awake() { controllerEvents = GetComponent <VRTK_ControllerEvents>(); controllerActions = GetComponent <VRTK_ControllerActions>(); VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller); destroyColliderOnDisable = false; var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand)); }
// Token: 0x060015EA RID: 5610 RVA: 0x000779C8 File Offset: 0x00075BC8 protected virtual void OnEnable() { this.destroyColliderOnDisable = false; SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(base.gameObject); this.defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand)); VRTK_PlayerObject.SetPlayerObject(base.gameObject, VRTK_PlayerObject.ObjectTypes.Controller); this.triggerRumble = false; this.CreateTouchCollider(); this.CreateTouchRigidBody(); }
protected virtual void SetControllerAttachPoint() { //If no attach point has been specified then just use the tip of the controller if (controllerReference.model != null && originalControllerAttachPoint == null) { //attempt to find the attach point on the controller SDK_BaseController.ControllerHand handType = VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject); string elementPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, handType); attemptSetCurrentControllerAttachPoint = StartCoroutine(SetCurrentControllerAttachPoint(elementPath, 10, 0.1f)); } }
// Token: 0x06001549 RID: 5449 RVA: 0x000757A0 File Offset: 0x000739A0 protected virtual string GetElementPath(string currentPath, SDK_BaseController.ControllerElements elementType) { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(this.controllerAlias); string controllerElementPath = VRTK_SDK_Bridge.GetControllerElementPath(elementType, controllerHand, false); if (!(currentPath.Trim() == "") || controllerElementPath == null) { return(currentPath.Trim()); } return(controllerElementPath); }
/// <summary> /// The ConfigureControllerPaths method is used to set up the model element paths. /// </summary> public virtual void ConfigureControllerPaths() { cachedElements = new Dictionary <string, Transform>(); SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(controllerAlias); modelElementPaths.bodyModelPath = GetElementPath(modelElementPaths.bodyModelPath, SDK_BaseController.ControllerElements.Body); modelElementPaths.triggerModelPath = GetElementPath(modelElementPaths.triggerModelPath, SDK_BaseController.ControllerElements.Trigger); modelElementPaths.leftGripModelPath = GetElementPath(modelElementPaths.leftGripModelPath, SDK_BaseController.ControllerElements.GripLeft); modelElementPaths.rightGripModelPath = GetElementPath(modelElementPaths.rightGripModelPath, SDK_BaseController.ControllerElements.GripRight); modelElementPaths.touchpadModelPath = GetElementPath(modelElementPaths.touchpadModelPath, SDK_BaseController.ControllerElements.Touchpad); modelElementPaths.buttonOneModelPath = GetElementPath(modelElementPaths.buttonOneModelPath, SDK_BaseController.ControllerElements.ButtonOne); modelElementPaths.buttonTwoModelPath = GetElementPath(modelElementPaths.buttonTwoModelPath, SDK_BaseController.ControllerElements.ButtonTwo); modelElementPaths.systemMenuModelPath = GetElementPath(modelElementPaths.systemMenuModelPath, SDK_BaseController.ControllerElements.SystemMenu); modelElementPaths.startMenuModelPath = GetElementPath(modelElementPaths.systemMenuModelPath, SDK_BaseController.ControllerElements.StartMenu); }
protected virtual void AttemptSecondaryGrab(VRTK_InteractableObject grabbableObject) { if (attemptSecondaryGrab) { SDK_BaseController.ControllerHand currentHand = VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject); VRTK_ControllerReference oppositeControllerReference = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetOppositeHand(currentHand)); if (VRTK_ControllerReference.IsValid(oppositeControllerReference)) { secondaryInteractTouch = (secondaryInteractTouch == null ? oppositeControllerReference.scriptAlias.GetComponentInChildren <VRTK_InteractTouch>() : secondaryInteractTouch); secondaryInteractGrab = (secondaryInteractGrab == null ? oppositeControllerReference.scriptAlias.GetComponentInChildren <VRTK_InteractGrab>() : secondaryInteractGrab); secondaryInteractTouch.ForceStopTouching(); secondaryInteractTouch.ForceTouch(grabbableObject.gameObject); secondaryInteractGrab.AttemptGrab(); } } }
protected virtual void Awake() { cachedElements = new Dictionary <string, Transform>(); var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); if (modelElementPaths.bodyModelPath.Trim() == "") { modelElementPaths.bodyModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Body, controllerHand); } if (modelElementPaths.triggerModelPath.Trim() == "") { modelElementPaths.triggerModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Trigger, controllerHand); } if (modelElementPaths.leftGripModelPath.Trim() == "") { modelElementPaths.leftGripModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripLeft, controllerHand); } if (modelElementPaths.rightGripModelPath.Trim() == "") { modelElementPaths.rightGripModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripRight, controllerHand); } if (modelElementPaths.touchpadModelPath.Trim() == "") { modelElementPaths.touchpadModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Touchpad, controllerHand); } if (modelElementPaths.buttonOneModelPath.Trim() == "") { modelElementPaths.buttonOneModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonOne, controllerHand); } if (modelElementPaths.buttonTwoModelPath.Trim() == "") { modelElementPaths.buttonTwoModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonTwo, controllerHand); } if (modelElementPaths.systemMenuModelPath.Trim() == "") { modelElementPaths.systemMenuModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.SystemMenu, controllerHand); } if (modelElementPaths.startMenuModelPath.Trim() == "") { modelElementPaths.startMenuModelPath = VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.StartMenu, controllerHand); } }
// Token: 0x0600110C RID: 4364 RVA: 0x00064298 File Offset: 0x00062498 protected virtual Transform GetTransform(Transform setTransform, SDK_BaseController.ControllerElements findElement) { Transform result = null; if (setTransform != null) { result = setTransform; } else if (this.controllerEvents != null) { GameObject modelAliasController = VRTK_DeviceFinder.GetModelAliasController(this.controllerEvents.gameObject); if (modelAliasController != null && modelAliasController.activeInHierarchy) { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(this.controllerEvents.gameObject); string controllerElementPath = VRTK_SDK_Bridge.GetControllerElementPath(findElement, controllerHand, true); result = ((controllerElementPath != null) ? modelAliasController.transform.Find(controllerElementPath) : null); } } return(result); }
// Token: 0x06001538 RID: 5432 RVA: 0x00074FE0 File Offset: 0x000731E0 public virtual void PopulateHighlighters() { this.highlighterOptions = new Dictionary <string, object>(); this.highlighterOptions.Add("resetMainTexture", true); VRTK_BaseHighlighter vrtk_BaseHighlighter = VRTK_BaseHighlighter.GetActiveHighlighter(this.controllerAlias); if (vrtk_BaseHighlighter == null) { vrtk_BaseHighlighter = this.controllerAlias.AddComponent <VRTK_MaterialColorSwapHighlighter>(); } SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(this.controllerAlias); vrtk_BaseHighlighter.Initialise(null, this.highlighterOptions); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonOne, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.buttonOne); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonTwo, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.buttonTwo); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Body, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.body); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripLeft, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.gripLeft); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripRight, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.gripRight); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.StartMenu, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.startMenu); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.SystemMenu, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.systemMenu); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Touchpad, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.touchpad); this.AddHighlighterToElement(this.GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Trigger, controllerHand, false)), vrtk_BaseHighlighter, this.elementHighlighterOverrides.trigger); }
private Transform GetTransform(Transform setTransform, SDK_BaseController.ControllerElements findElement) { Transform returnTransform = null; if (setTransform) { returnTransform = setTransform; } else { var modelController = VRTK_DeviceFinder.GetModelAliasController(controllerActions.gameObject); if (modelController && modelController.activeInHierarchy) { var controllerHand = VRTK_DeviceFinder.GetControllerHand(controllerActions.gameObject); var elementPath = VRTK_SDK_Bridge.GetControllerElementPath(findElement, controllerHand, true); returnTransform = modelController.transform.Find(elementPath); } } return(returnTransform); }
protected virtual Transform GetTransform(Transform setTransform, SDK_BaseController.ControllerElements findElement) { Transform returnTransform = null; if (setTransform) { returnTransform = setTransform; } else if (controllerEvents != null) { GameObject modelController = VRTK_DeviceFinder.GetModelAliasController(controllerEvents.gameObject); if (modelController && modelController.activeInHierarchy) { SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(controllerEvents.gameObject); string elementPath = VRTK_SDK_Bridge.GetControllerElementPath(findElement, controllerHand, true); returnTransform = modelController.transform.FindChild(elementPath); } } return(returnTransform); }
/// <summary> /// The InitaliseHighlighters method sets up the highlighters on the controller model. /// </summary> public void InitaliseHighlighters() { highlighterOptions = new Dictionary <string, object>(); highlighterOptions.Add("resetMainTexture", true); VRTK_BaseHighlighter objectHighlighter = VRTK_BaseHighlighter.GetActiveHighlighter(gameObject); if (objectHighlighter == null) { objectHighlighter = gameObject.AddComponent <VRTK_MaterialColorSwapHighlighter>(); } var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject); objectHighlighter.Initialise(null, highlighterOptions); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonOne, controllerHand)), objectHighlighter, elementHighlighterOverrides.buttonOne); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonTwo, controllerHand)), objectHighlighter, elementHighlighterOverrides.buttonTwo); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Body, controllerHand)), objectHighlighter, elementHighlighterOverrides.body); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripLeft, controllerHand)), objectHighlighter, elementHighlighterOverrides.gripLeft); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripRight, controllerHand)), objectHighlighter, elementHighlighterOverrides.gripRight); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.SystemMenu, controllerHand)), objectHighlighter, elementHighlighterOverrides.systemMenu); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Touchpad, controllerHand)), objectHighlighter, elementHighlighterOverrides.touchpad); AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Trigger, controllerHand)), objectHighlighter, elementHighlighterOverrides.trigger); }
private void SetControllerAttachPoint() { //If no attach point has been specified then just use the tip of the controller if (controllerAttachPoint == null) { //attempt to find the attach point on the controller var defaultAttachPoint = transform.Find(VRTK_SDK_Bridge.GetControllerElementPath(SDK_Base.ControllerElelements.AttachPoint, VRTK_DeviceFinder.GetControllerHand(gameObject))); if (defaultAttachPoint != null) { controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { var autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } } }
public override void AttemptGrabObject() { //Finds position of both controllers, check if any of them in the sphere collider, if so cannot grab. GameObject objectToGrab = GetGrabbableObject(); if (firstGrabber != null && objectToGrab.layer == (int)ObjectLayer.Heavy) { firstGrabber = objectToGrab.GetComponent <VRTK_InteractableObject>().GetGrabbingObject(); if (VRTK_DeviceFinder.GetControllerHand(firstGrabber) == SDK_BaseController.ControllerHand.Left) { secondGrabber = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.RightController).gameObject; } else { secondGrabber = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.LeftController).gameObject; } } GameObject leftCtrler = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.LeftController).gameObject; GameObject rightCtrler = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.RightController).gameObject; hitCollidersLeft = Physics.OverlapSphere(leftCtrler.transform.position, 0.04f); hitCollidersRight = Physics.OverlapSphere(rightCtrler.transform.position, 0.04f); penaltyCheck = Physics.OverlapBox(this.transform.position, new Vector3(0.1f, 0.1f, 0.1f), Quaternion.identity); bool ungrabbable = false; foreach (Collider c in penaltyCheck) { if (c.gameObject.tag == "Penalty") { ScoreCheck.instance.Deductscore(1); } } foreach (Collider col in hitCollidersLeft) { if (col.gameObject.layer == (int)ObjectLayer.Ungrabbable || col.gameObject.layer == (int)ObjectLayer.Tray) { ungrabbable = true; } } foreach (Collider col in hitCollidersRight) { if (col.gameObject.layer == (int)ObjectLayer.Ungrabbable || col.gameObject.layer == (int)ObjectLayer.Tray) { ungrabbable = true; } } // GameObject proceduralSnapGameObject = objectToGrab; bool beneathStack = false; //handle grabbing of object in the stack if (proceduralSnapGameObject != null) { while (proceduralSnapGameObject.GetComponent <VRTK_InteractableObject>().GetStoredSnapDropZone() != null) { proceduralSnapGameObject = proceduralSnapGameObject.GetComponent <VRTK_InteractableObject>().GetStoredSnapDropZone(). gameObject.transform.parent.gameObject; } if (proceduralSnapGameObject.GetComponent <ProceduralSnap>()) { ProceduralSnap PS = proceduralSnapGameObject.GetComponent <ProceduralSnap>(); for (int i = 0; i < PS.snapZones.Length; i++) { if (PS.snapZones[i].GetCurrentSnappedObject() == objectToGrab) { if (PS.snapZones[i].proceduralSnapPos <= PS.snapCount - 1) { beneathStack = true; } if (PS.snapZones[i].proceduralSnapPos == 7) //check if its 2nd highest in the stack due to bypassing snapcount for 8th and 7th sideplate { if (PS.snapZones[i].proceduralSnapPos < PS.snapCount) { beneathStack = true; } } } } } } // //Using this for normal grab and to check which controller grab first so //the second grab will work better if (objectToGrab != null) { if (objectToGrab.layer == (int)ObjectLayer.Ungrabbable && !ungrabbable || objectToGrab.layer == (int)ObjectLayer.Tray && !ungrabbable) { if (objectToGrab.tag == "Sideplate") { if (objectToGrab.GetComponent <VRTK_InteractableObject>().GetStoredSnapDropZone() == null) { PerformGrabAttempt(objectToGrab); objectToGrab.GetComponent <SphereCollider>().enabled = false; } else if (objectToGrab.GetComponent <VRTK_InteractableObject>().GetStoredSnapDropZone() != null) { if (!beneathStack) { PerformGrabAttempt(objectToGrab); } } } else { PerformGrabAttempt(objectToGrab); objectToGrab.GetComponent <SphereCollider>().enabled = false; } } if (!beneathStack && objectToGrab.layer != (int)ObjectLayer.Ungrabbable && objectToGrab.layer != (int)ObjectLayer.Tray) { PerformGrabAttempt(objectToGrab); } } else { grabPrecognitionTimer = Time.time + grabPrecognition; } }
protected virtual void ManageControllerModelListeners(bool register) { ManageControllerModelListener(register, VRTK_DeviceFinder.GetControllerHand(gameObject)); }
protected GameObject GetControllerModelFromController(GameObject controller) { return(GetControllerModel(VRTK_DeviceFinder.GetControllerHand(controller))); }
protected virtual void SetControllerAttachPoint() { //If no attach point has been specified then just use the tip of the controller if (controllerReference.model != null && originalControllerAttachPoint == null) { //attempt to find the attach point on the controller Transform defaultAttachPoint = controllerReference.model.transform.Find(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject))); if (defaultAttachPoint != null) { controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { var autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } } }