public void ActivateAura(bool activate) { child.gameObject.SetActive(activate); auraIsActive = activate; if (!activate) { foreach (RaycastHit2D box in boxes) { MovebleItems moveble = box.transform.gameObject.GetComponent <MovebleItems>(); moveble.resetValues(false); } boxes = new RaycastHit2D[0]; } }
// Update is called once per frame private void FixedUpdate() { if (auraIsActive) { RaycastHit2D[] newBoxes = Physics2D.CircleCastAll(transform.position, affectArea, Vector3.left, 0, layer2BeAffected); if (newBoxes.Length > 0) { foreach (RaycastHit2D box in newBoxes) { MovebleItems moveble = box.transform.gameObject.GetComponent <MovebleItems>(); if (!moveble.IsActivate) { moveble.resetValues(true); } } boxes = newBoxes; } } }