title: Character attacks sometimes collide when collision isn't taking place. - Unity Collision
body: <p>I'm working on a 3D top down game in Unity 2021.3.4f1 (HDRP).  In the game I have a player character that's already placed in the game scene before it starts and enemy characters that are instantiated at random spawn points within a certain distance of the player.  The enemies and player can use melee attacks to attack each other.  Once in a blue moon the player attacks will hit an enemy that the attacks aren't colliding with.  This also happens vice versa, where an enemy's attacks will hit the player when the colliders aren't colliding.  Otherwise the attacks and collision work flawlessly.  I'm 90% sure that this wasn't occurring before I upgraded the engine from a prior 2019 version.  Any ideas to as why this could be happening?</p>
  <p>I'm using an attack pooling system, where attacks are created with their set info (i.e. attack damage, how many characters can be hit with a single attack etc.) and then thrown into a pool of attack objects.  After the attack is registered and has finished, it's deregistered and kept in the pool for further use.  I'm using a bool return method called IsCollided that takes in the attacks information as a parameter to detect the collision:</p>
  <pre><code>private bool IsCollided(AttackInfo info)
      {
          foreach (KeyValuePair&lt;TriggerDetector, List&lt;Collider&gt;&gt; data in 
          control.animationProgress.CollidingBodyParts)
          {
              foreach (Collider collider in data.Value)
              {
                  foreach (AttackPartType part in info.AttackParts)
                  {
                      if (info.Attacker.GetAttackingPart(part) == collider.gameObject)
                      {
                          //We want to get the attack scriptable object
                          control.animationProgress.Attack = info.AttackAbility;
                          //We also want to get the attacker
                          control.animationProgress.Attacker = info.Attacker;
                          //We also want to get the damaged trigger
                          control.animationProgress.DamagedTrigger = data.Key;
                          //And then we return true because the attack has collided 
                          return true;
                      }
                  }
              }
          }
          //Otherwise it hasn't collided
          return false;
      }
  </code></pre>
  <p>Basically what I'm trying to say is that attacks will sometimes trigger hit reactions when they're not actually colliding with another character. you could be 15 feet away from a character and you'll collide with them. Most of the time it works when it should. But on a rare occasion this issue occurs.</p>
  <p>I'm using a &quot;TriggerDetector.cs&quot; script that has an OnTriggerEnter() method that stores all of the collisions that interact with each character's colliders in a list. Those are then removed from the list using an OnTriggerExit() method that removes the collided with objects when the collision is no longer occurring. Aside from that there's tons of checks which detect if the attack is allowed to collide. There's no issues with that though as the attacks always collide when they should be aside from this issue.</p>
  <p>Any help would be greatly appreciated!</p>