public void Detonate() { foreach (GameObject enemy in enemies) { iSquashable s = enemy.GetComponent <iSquashable>(); if (s != null) { s.Squash(); } } }
// Update is called once per frame void Update() { RaycastHit hit; if (Physics.SphereCast(transform.position, radius, transform.forward, out hit, Mathf.Infinity, layerMask.value)) { GameObject other = hit.collider.gameObject; iSquashable enemy = other.GetComponent <iSquashable>(); if (enemy != null) { if (enemy.CanSquash()) { EnableSquashIndicator(); canSquish = true; curTarget = other.gameObject; //Debug.Log("Can Squash"); } else { canSquish = false; } } else { canSquish = false; } } else { canSquish = false; } if (Time.time >= nextSquishTime) { if (canSquish) { EnableSquashIndicator(); if (Input.GetAxis("Fire1") != 0) { Squash(); handAnim.SetTrigger("pinch"); //Anim } } else { DisableSquashIndicator(); } } if (!canSquish && Input.GetAxis("Fire1") != 0) { handAnim.SetTrigger("pinchFail"); //Anim } }