Issue with child object collider moving through other colliders

So I’m having a bit of an issue with implementing a shield for my player. I have a shield child object on my player which has both a box collider and a rigidbody, and I have a capsule collider and a rigidbody on my parent player object as well. I’m able to detect from the enemy script whether the enemy collides with the player or shield, but as you can see, the shield’s collider passes through the enemy which allows my player to collide with the enemy as well, which I obviously don’t want.

When the player holds the shield button, i enable the shield’s collider (as in set the gameobject to active) and don’t want anything to go through the shield collider and touch the player. Removing the rigidbody on the shield fixes this issue but then collisions are only detected on the player and not the shield.

Any ideas as to why the shield collider moves through other gameobjects? (the enemy also has a capsule collider and a rigidbody and none of the colliders are set to trigger). Of course if there’s a better way to implement my shield functionality all together, I’m open to that as well.

][1]

Well, the basic question here is: What collision detection is your rigidbody set to? If it is discrete (the normal option) things will likely clip through, depending on how fast they move.
Try continous dynamic, and if that doesn’t work, go for continous speculative.

You did not specify what kind of shield it is. If it is an energy bubble, maybe a distance check each frame would work (if there are not too many enemies, else it would be quite costly). If you are using navmesh agents, adding an obstacle to the player would prevent enemies from entering it.
If it is a physical shield, you can do a few raycast from the enemy weapon and see if any of it hit the shield and then block the movement.

Hope I could help :slight_smile: