public void OnTriggerEnter(Collider other) { TargetCube targetCube = other.GetComponent <TargetCube>(); if (targetCube != null) { targetCube.DestroyObject(); } }
public void OnTriggerEnter(Collider other) { TargetCube targetCube = other.GetComponentInParent <TargetCube>(); if (targetCube != null) { bool hasEnoughVelocity = (saberEdgeVelocity.magnitude >= GameManager.Instance.slashIntensityThreshold) ? true : false; bool hasCorrectAngle = (Vector3.Dot(-targetCube.transform.up, saberEdgeVelocity.normalized) >= GameManager.Instance.slashAngleThreshold) ? true : false; if (hasEnoughVelocity && hasCorrectAngle && saberColor == targetCube.cubeColor) { targetCube.CorrectHit(); VRControllerManager.instance.PlayHaptic(transform.parent.gameObject, 10, .1f, .01f); } else { targetCube.DestroyObject(); } } }