Yes, you need to create a GameObject using the trigger collider and place it in a layer that interacts with the playerâs layer.
No, you do not need to add a Rigidbody to a new GameObject , the parent hard drive already makes it a dynamic collider, so you will receive OnTrigger events.
As a side note, just to keep things organized, if you are creating an enemy child, do not put it in the playerâs layer. For example, in the future you may need to disable the collision of a playerâs layer with itself. In addition, if your player interacts with many objects, I would put one trigger per player instead of enemies on a separate PlayerTrigger layer, so that everything was just fine.
Is there an easier way? Not really. You definitely need not to interact between the player and the enemy colliders, but some kind of interaction between them. Therefore, one of them should cover two layers, or the entire interaction will be described by one bool. The physics engine processes a lot of information at a time, so you can set all the layers and collisions you want, but during the physics cycle you no longer control what is happening. You cannot force the engine to ignore collisions between two objects. With only 32 layers, and if they behave tough, they really represent a great optimization. If you are concerned about the performance of creating another layer, turn off the interaction between layers that you donât need, such as a trigger layer, floor and walls, or layers that donât even touch.
Your alternative does all this by code, which is even less elegant. One baby capsule on the player doesnât sound so bad right now, does it?
source share