public override void HitCheck() { List <Collider> hurtboxes = new List <Collider>(); LayerMask hurtboxMask = LayerMask.GetMask("Hurtbox"); hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.2f + offset)), 0.4f)); for (int h = 0; h < hitCircles.Count; h++) { hurtboxes.AddRange(Physics.OverlapSphere(hitCircles[h].position, hitCircles[h].radius, hurtboxMask)); } for (int i = 0; i < hurtboxes.Count; i++) { int hurtboxID = hurtboxes[i].gameObject.GetInstanceID(); if (BoxesHit.Contains(hurtboxID)) { continue; } else { Hurtbox hb = hurtboxes[i].GetComponent <Hurtbox>(); if (hitID != hb.hitID) { BoxesHit.Add(hurtboxID); Vector3 dir = direction; if (attackStep == 9) { dir = hurtboxes[i].transform.position - transform.position; } hb.Damage(attackType, damage, knockback, weightClass, dir, ownerStatus); } } } }
private void OnTriggerEnter(Collider other) { //Wall Collision if (other.gameObject.layer == 8 && activeBox) { Explode(); } //Entity Collision bool hit = false; if (other.gameObject.tag == "Hurtbox" && activeBox) { int hurtboxID = other.gameObject.GetInstanceID(); if (!BoxesHit.Contains(hurtboxID)) { Hurtbox hb = other.GetComponent <Hurtbox>(); if (hitID != hb.hitID) { BoxesHit.Add(hurtboxID); hit = hb.Damage(attackType, damage, knockback, weightClass, direction, ownerStatus); } } if (hit) { Explode(); } } //Breakable Collision if (other.gameObject.tag == "Neutral") { //Damage Entity (Break the thing) } }
public override void HitCheck() { List <Collider> hurtboxes = new List <Collider>(); LayerMask hurtboxMask = LayerMask.GetMask("Hurtbox"); switch (attackStep) { case 1: hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.2f + offset)), 0.4f)); break; case 2: hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.2f + offset)), 0.4f)); break; case 3: hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.2f + offset)), 0.45f)); Vector3 newDir = (Quaternion.AngleAxis(40, Vector3.forward) * direction); hitCircles.Add(new SphereHitbox(Adjust() + (newDir * (0.2f + offset)), 0.35f)); newDir = (Quaternion.AngleAxis(-40, Vector3.forward) * direction); hitCircles.Add(new SphereHitbox(Adjust() + (newDir * (0.2f + offset)), 0.35f)); break; case 4: hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.32f + offset)), 0.35f)); hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.8f + offset)), 0.35f)); break; case 5: hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.5f + offset)), 0.57f)); hitCircles.Add(new SphereHitbox(Adjust() + (direction * (0.1f + offset)), 0.57f)); break; } for (int h = 0; h < hitCircles.Count; h++) { hurtboxes.AddRange(Physics.OverlapSphere(hitCircles[h].position, hitCircles[h].radius, hurtboxMask)); } for (int i = 0; i < hurtboxes.Count; i++) { int hurtboxID = hurtboxes[i].gameObject.GetInstanceID(); if (BoxesHit.Contains(hurtboxID)) { continue; } else { Hurtbox hb = hurtboxes[i].GetComponent <Hurtbox>(); if (hitID != hb.hitID) { BoxesHit.Add(hurtboxID); Vector3 dir = direction; hb.Damage(attackType, damage, knockback, weightClass, dir, ownerStatus); } } } }
private void OnTriggerEnter(Collider other) { //Wall Collision if (other.gameObject.layer == 8) { Vector3 adjustElevation = Vector3.zero; adjustElevation.y = elevation; adjustElevation.z = -elevation; direction.z = direction.y; anchorPos = anchorPos + (direction * speed * Time.fixedDeltaTime * .35f); rigidBody.MovePosition(anchorPos + adjustElevation); if (activeBox) { SoundMaker.i.PlaySound("Stab", transform.position, 0.5f, 32); } activeBox = false; speed = 0; dropRate = 0; dropAcceleration = 0; rotation = 0; } //Enemy Collision if (other.gameObject.tag == "Hurtbox" && activeBox) { int hurtboxID = other.gameObject.GetInstanceID(); if (!BoxesHit.Contains(hurtboxID)) { Hurtbox hb = other.GetComponent <Hurtbox>(); if (hitID != hb.hitID) { BoxesHit.Add(hurtboxID); hb.Damage(attackType, damage, knockback, weightClass, direction, ownerStatus); } } } //Breakable Collision if (other.gameObject.tag == "Neutral") { //Damage Entity (Break the thing) } }