Replacing OverlapSphere with colliders (Detecting weapon collision with enemies - SOLVED)

So i basically have this really basic combat system that i made off Brackeys’ tutorials…but now i want it to be more complex and involve colliders instead of Physics.OverlapSphere(). So i just need to ask how do i create a replacement for this single line of code

Collider[] hitEnemies = Physics.OverlapSphere(attackpoint.position, attackradius, enemies);

but this time using colliders. just to clarify, I intend to make a combat system where the weapon has two colliders – One on the Main Attacking part and another on other parts which will deal significantly less damage. So i have divided the mesh into two parts giving them separate colliders.

It would be great if you could just help out with the first issue though i think i can figure the multiple colliders out myself. Big Thanks in Advance.

Here is my messy combat script for reference

[182854-playercombat.txt|182854]

EDIT: I managed to get a few things done that i think should’ve worked. I have updated my player combat script. However, things seem to be not working too well…instead of interacting with the enemies…the weapon is pushing them around. I want the weapon to phase through the enemy collider.

the scripts attached to my weapons are

This is the WeaponCollider script to manage the different collisions

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponCollider : MonoBehaviour
{
   public Collider maincollider;
   public Collider secondarycollider;
   public PlayerCombat playercombat;

   public bool maincollides;
   public bool secondarycollides;

   void Update()
   {
     if(!maincollides && !secondarycollides)
     {
       playercombat.hitEnemies.Clear();
     }
   }
}

The script attached to my main collider (the one that deals more damage) is

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainCollision : MonoBehaviour
{
    public WeaponCollider collidermanager;
    public bool checking;
    public Collider enemytocheck;
    public bool result;

    void OnTriggerEnter(Collider collider)
    {
      collidermanager.maincollides = false;
      if(collider.gameObject.layer == LayerMask.GetMask("enemy"))
      {
        collidermanager.playercombat.hitEnemies.Add(collider);
      }
    }

    void OnTriggerStay(Collider collider)
    {
      if(checking)
      {
        if(enemytocheck == collider)
        {
          result = true;
          ReturnCheck();
        }
        else
        {
          result = false;
          ReturnCheck();
        }
      }
    }

    void OnTriggerExit(Collider collider)
    {
      collidermanager.maincollides = false;
    }

    public void CheckEnemy(Collider enemy)
    {
      checking = true;
      enemytocheck = enemy;
    }

    public bool ReturnCheck()
    {
      return (result);
    }
}

The script attached to my secondary collider is

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SecondaryCollision : MonoBehaviour
{
  public WeaponCollider collidermanager;

  void OnTriggerEnter(Collider collider)
  {
    collidermanager.secondarycollides = false;
    if(collider.gameObject.layer == LayerMask.GetMask("enemy"))
    {
      collidermanager.playercombat.hitEnemies.Add(collider);
    }
  }

  void OnTriggerExit(Collider collider)
  {
    collidermanager.secondarycollides = false;
  }
}

The maxdamage and mindamage variables in the combat script are the damage values for the main and secondary collider respectively. Please Help!!

the collider itself in the editor has a property called “is Trigger” you need to click it