Question about Hitboxes/Colliders
So I've been working on this simple little game where you're a person made of primitive shapes using a sword made of primitive shapes to kill monsters made of primitive shapes, just as a personal project while finishing the Junior Programming path on learn.unity. I've been struggling a bit recently, trying to implement attacks for the enemies that can hurt the player.
So far, for the player's attacks, I just made an attack animation where the player swings around a sword that was tagged with "Weapon". All enemies have an OnCollisionEnter where they execute their Die() script when they collide with a gameObject tagged "Weapon". Later I made it so the sword was only tagged "Weapon" during an attack animation using the Animation OnStateEnter and OnStateExit functions. A bit scuffed, but this worked great.
But when it comes to Enemy attacks, I wanted the hitbox to really only be out during the part where the enemy's hands are out so the player has time to react to the windup animation and I can maybe implement blocking later.
So I added an empty GameObject as a Child of my Enemy Prefab, called it "AttackHitbox", gave it a Box Collider with a trigger and a Script with just an OnTriggerEnter that tells me if the player enters the trigger. Then I read about Animation Events and used those to set the GameObject as Active/Inactive during the appropriate frames of the Attack Animation. But for some reason, this just does not work and the OnTriggerEnter event of the Hitbox does not get triggered.
I tested whether the object properly activates by making the hitbox visible too and it does, but it still doesn't trigger the script. Can anyone who has done something similar before tell me why, or perhaps how they implemented it?