void ForceGrabObject(Interactable interactable) { if (interactable.hoveringHand != null) { lastOwnerHand = interactable.hoveringHand; } if (lastOwnerHand && !lastOwnerHand.ObjectIsAttached(this.gameObject)) { //Debug.Log("Hover-trigger-grabbed " + gameObject.name); isBeingGrabbed = true; if (m_throwable == null) { m_throwable = GetComponent <Valve.VR.InteractionSystem.Throwable>(); } interactable .hoveringHand .AttachObject( this.gameObject, GrabTypes.Pinch, //m_interactable.useHandObjectAttachmentPoint, m_throwable.attachmentFlags, m_throwable.attachmentOffset); } if (_turnGameObjectOnWhenForceGrabbed) { gameObject.SetActive(true); } }
// Start is called before the first frame update void Awake() { m_GLHandleVisuals_Group = GetComponent <GLHandleVisuals_Group>(); if (m_InteractableHoverEvents == null) { m_InteractableHoverEvents = GetComponent <Valve.VR.InteractionSystem.InteractableHoverEvents>(); m_interactable = GetComponent <Valve.VR.InteractionSystem.Interactable>(); m_throwable = GetComponent <Valve.VR.InteractionSystem.Throwable>(); targetGO = gameObject; } if (m_InteractableHoverEvents == null) { Transform tmpTransform = transform; for (int i = 0; i < 100; i++) { tmpTransform = tmpTransform.parent; if (tmpTransform != null) { m_InteractableHoverEvents = tmpTransform.GetComponent <Valve.VR.InteractionSystem.InteractableHoverEvents>(); m_interactable = tmpTransform.GetComponent <Valve.VR.InteractionSystem.Interactable>(); m_throwable = tmpTransform.GetComponent <Valve.VR.InteractionSystem.Throwable>(); targetGO = tmpTransform.gameObject; } else { break; } if (m_InteractableHoverEvents != null) { break; } } if (m_InteractableHoverEvents == null) { m_InteractableHoverEvents = transform.GetComponentInChildren <Valve.VR.InteractionSystem.InteractableHoverEvents>(); m_interactable = transform.GetComponent <Valve.VR.InteractionSystem.Interactable>(); m_throwable = transform.GetComponent <Valve.VR.InteractionSystem.Throwable>(); targetGO = transform.gameObject; } else if (m_InteractableHoverEvents == null) { Debug.Log("[" + transform.parent.name + "/" + gameObject.name + "] WARNING: Hovering on these gizmos will not work because the script couldn't auto-find the InteractableHoverEvents it should subscribe to. Assign it manually in the inspector."); } } if (m_interactable == null && m_InteractableHoverEvents != null) { m_interactable = m_InteractableHoverEvents.GetComponent <Valve.VR.InteractionSystem.Interactable>(); } m_GLHandleVisuals_Group.interactableLinkedTo = getInteractable; }
void OnCollisionEnter(Collision collision) { Valve.VR.InteractionSystem.Throwable _object = collision.transform.GetComponent <Valve.VR.InteractionSystem.Throwable>(); if (_object) { // set th normalMirror.SetActive(false); shatterMirror.SetActive(true); // card.SetActive(true); wallTextCanvas.GetComponent <Animator>().SetTrigger("triggerOnOff"); // play sound GetComponent <AudioSource>().Play(); // Puzzle Manager GameObject.Find("PuzzleManager").GetComponent <PuzzleManager>().OnPuzzleTwoSolved(); } }
private void Start() { throwable = GetComponent <Valve.VR.InteractionSystem.Throwable>(); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); Throwable = GetComponent <Valve.VR.InteractionSystem.Throwable>(); }
void GetReferences() { m_interactable = GetComponent <Valve.VR.InteractionSystem.Interactable>(); m_interactableHE = GetComponent <Valve.VR.InteractionSystem.InteractableHoverEvents>(); m_throwable = GetComponent <Valve.VR.InteractionSystem.Throwable>(); }