Detect if object is within Cube / Box Collider

Hey all,

I’ve got a cube sticking out of each player. I’m trying to detect all other players) within that cube when a melee swing occurs.
I have the melee swing hooked up, and I have the object retrieved in my script:

var meleeVolume = shooter.transform.FindChild("MeleeDamageVolume");

The MeleeDamageVolume has a Box Collider, and has the Is Trigger flag set to true.
I’m not sure of the pattern, but I believe it should be possible to detect other players within this cube fairly easily.

Any advice would be much appreciated.

Edit: I have hooked up a script to this collider and am using the events for enter/exit triggers. It’s detecting it at very weird times… like just when running around my map with nothing in front of me, and it hardly ever detects another player standing in front of me (although sometimes it does, but then once it does it doesn’t call the exit event when i move away from that player).

I’ve had similar problems with OnEnter/OnExit recently too. I found they behave a little strangely when you’re dealing with multiple objects. For example, if object ‘A’ enters, then object ‘B’ enters, you’ll get two OnEnter events. BUT, if object ‘A’ then exits, you might not get an OnExit for it. It’s like a second “Enter” cancels an “Exit”… sometimes… or something. I had to end up writing some complicated stuff to record all the coming and going manually.

I ended up just doing a BoundingBox intersects check and it’s working without fault. The check only occurs on a melee swing, not every frame, so it is probably pretty efficient.