void OnCollisionEnter(Collision col) { Debug.Log(col.collider.tag); if (col.collider.tag == "Mole") { Moles mole = col.gameObject.GetComponent <Moles>(); if (col.collider.tag == "Mole" && (mole.state == Moles.State.GOING_UP) || (mole.state == Moles.State.UP)) { Debug.Log("Destroy"); mole.state = Moles.State.GOING_DOWN; if (col.gameObject != temp) { temp = null; } if (temp == null) { molesScript.molesHit += 1; } temp = col.gameObject; if (gameObject.name == "Left") { haptics.vibrate(true); } else { haptics.vibrate(false); } } } if (col.collider.tag == "Player") { Physics.IgnoreCollision(col.gameObject.GetComponent <Collider>(), GetComponent <Collider>()); } }
void OnCollisionEnter(Collision col) { ///TODO: Left Hand not doing it correctly all of the times if (col.collider.tag == "Enemy" || col.collider.tag == "Mole") { //Left Hand if (gameObject.name == "hand_left" && OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger) >= 0.1 && OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger) >= 0.1 /*&& hand.velocity.magnitude >= speed*/) { if (col.collider.tag == "Mole") { Debug.Log("Destroy"); Moles mole = col.gameObject.GetComponent <Moles> (); mole.state = Moles.State.GOING_DOWN; if (col.gameObject != temp) { temp = null; } if (temp == null) { molesScript.molesHit += 1; } temp = col.gameObject; haptics.vibrate(true); } else { Destroy(col.gameObject); haptics.vibrate(true); } //Destroy the enemy //Destroy (col.gameObject); } //Right Hand else if (gameObject.name == "hand_right" && OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger) >= 0.1 && OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) >= 0.1 /*&& hand.velocity.magnitude >= speed*/) { if (col.collider.tag == "Mole") { Moles mole = col.gameObject.GetComponent <Moles>(); mole.state = Moles.State.GOING_DOWN; if (col.gameObject != temp) { temp = null; } if (temp == null) { molesScript.molesHit += 1; } temp = col.gameObject; haptics.vibrate(false); } else { Destroy(col.gameObject); haptics.vibrate(false); } //Destroy the enemy //Destroy (col.gameObject); } } if (col.collider.tag == "Player") { Physics.IgnoreCollision(col.gameObject.GetComponent <Collider>(), GetComponent <Collider>()); } }