protected override void OnActionUp() { if (picked) { if (m_attaching) { m_picked = false; } else { Release(); } } else { if (transform.parent && transform.parent.parent) { VivePickable corkParent = transform.parent.parent.GetComponent <VivePickable>(); if (corkParent && corkParent.picked) { corkParent.Release(); } } } }
public void RemoveSelection() { if (!m_outlinedItem) { return; } if (m_targetVivePickable) { m_targetVivePickable.Release(); m_targetVivePickable = null; } Destroy(m_outlinedItem.gameObject); m_outlinedItem = null; }
private void OnCollisionEnter(Collision other) { if ((other.collider.isTrigger) || (other.collider.gameObject.name == "VitreHotte")) { return; } ViveCork otherCork = other.gameObject.GetComponent <ViveCork>(); if (otherCork) { return; } VivePickable otherPickable = other.gameObject.GetComponent <VivePickable>(); float collisionForce = other.relativeVelocity.magnitude * other.relativeVelocity.magnitude; if (other.rigidbody) { collisionForce *= other.rigidbody.mass; } else { collisionForce *= m_rigidbody.mass; } bool conditionsToExplode = (collisionForce >= 3) && !(m_pickable && m_pickable.picked) && !(otherPickable && otherPickable.picked); if (conditionsToExplode) { MakeGlassBreakSound(); FailCondition failCondition = new FailCondition(FailCondition.FailType.BrokenGlass); failCondition.failed = true; failCondition.failurePosition = transform.position; Watcher.ProvokeFail(failCondition, gameObject); Debug.Log("ColliXion avec " + other.collider.name + "(Force : " + Mathf.Round(collisionForce * 10) / 10 + " )"); Explode(other.contacts[0].point); } else { MakeGlassShockSound(other.contacts[0].point, other.relativeVelocity.magnitude); } }
protected override void OnActionDown() { if (!picked) { VivePickable itemToGrip = this; if (!m_released && transform.parent && transform.parent.parent) { VivePickable corkParent = transform.parent.parent.GetComponent <VivePickable>(); if (corkParent && !corkParent.picked) { itemToGrip = corkParent; } } itemToGrip.Grip(m_interactionWand); ReportInteraction(); } }
protected override void OnActionUp() { if (picked) { Release(); } else { ViveCork cork = GetComponent <ViveCork>(); if (cork && cork.transform.parent && cork.transform.parent.parent) { VivePickable corkParent = cork.transform.parent.parent.GetComponent <VivePickable>(); if (corkParent && corkParent.picked) { corkParent.Release(); } } } }
protected override void OnActionDown() { if (!picked) { VivePickable itemToGrip = this; if (m_itemType == XperItem.Erlenmeyer) { SmartFluwid smartFluwid = GetComponentInChildren <SmartFluwid>(); FluwidContainerEntry fluwidContainerEntry = smartFluwid.GetComponentInChildren <FluwidContainerEntry>(); if (fluwidContainerEntry.hasCork && fluwidContainerEntry.viveCork.picked) { itemToGrip = fluwidContainerEntry.viveCork; } } itemToGrip.Grip(m_interactionWand); ReportInteraction(); } }
public void SelectItem(Transform item) { if (m_outlinedItem) { return; } MeshFilter meshFilter = item.gameObject.GetComponent <MeshFilter>(); m_outlinedItem = Instantiate <MeshFilter>(m_outlinedPrefab); m_outlinedItem.mesh = meshFilter.mesh; m_outlinedItem.transform.SetParent(item, false); m_targetVivePickable = item.gameObject.GetComponent <VivePickable>(); if (m_targetVivePickable) { m_targetVivePickable.Grip(m_viveWand); } m_timeSinceSelection = 0; }
private void Awake() { m_meshRenderer = GetComponent <MeshRenderer>(); m_rigidbody = GetComponent <Rigidbody>(); m_pickable = GetComponent <VivePickable>(); }