public void slash() { /*if (Physics.Raycast(transform.position, Vector3.right * dir, out RH, 0.2f, LYRMSK)) * { * if (RH.collider.tag == "Malo") * RH.collider.GetComponent<Rigidbody>().AddForce(new Vector3(2,2,0),ForceMode.Impulse); * Stats.ADD_Power(14); * }*/ collis = null; collis = Physics.OverlapBox(transform.position + new Vector3(dir * 0.15f, 0, 0), new Vector3(0.2f, 0.3f, 0), Quaternion.identity, LYRMSK); foreach (Collider collider in collis) { daño = Mathf.RoundToInt(Random.Range(Stats.Daño[Stats.lvl_atq] - 3, Stats.Daño[Stats.lvl_atq] + 3)); if (collider.tag == "Malo") { collider.GetComponent <Rigidbody>().AddForce(new Vector3(2, 1, 0), ForceMode.Impulse); Stats.ADD_Power(7); GameObject GO = Instantiate(Daño_prefab, collider.transform.position + new Vector3(Random.Range(-0.55f, 0.55f), Random.Range(-0.23f, 0.23f), 0), Quaternion.identity); GO.GetComponentInChildren <Text>().text = daño.ToString(); Stats stats_malo = collider.GetComponentInChildren <Stats>(); stats_malo.ADD_Vida(-daño); } } collis = null; }
private void OnTriggerEnter(Collider collision) { if (collision.gameObject.tag != gameObject.tag) { int daño = Random.Range(5, 8); Instantiate(Explo[Sabor], transform.position, Quaternion.identity); GameObject GO = Instantiate(Daño_prefab, collision.transform.position + new Vector3(Random.Range(-0.55f, 0.55f), Random.Range(-0.23f, 0.23f), 0), Quaternion.identity); GO.GetComponentInChildren <Text>().text = daño.ToString(); Destroy(gameObject); Stats stats_malo = collision.GetComponentInChildren <Stats>(); stats_malo.ADD_Vida(-daño); } }