I'm trying to get a trigger volume to only fire once per compound collider instead of x times the number of subcolliders in the compound volume. Setup: Two cubes (cubes (1) and (2)) with colliders which share a parent (Rectangle) to form a compound collider, which then pass through a larger sphere trigger. Rectangle is only a transform and rigidbody. ---- Test 1: Detection script on Sphere Expectation: Sphere hit by Rectangle Result: Sphere hit by Cube (1) Sphere hit by Cube (2) ---- Test 2: Detection script on Rectangle Expectation: Rectangle hit by Sphere Result: Rectangle hit by Sphere Rectangle hit by Sphere --- It seems like no matter how I configure these objects, the trigger always fires twice. What am I doing wrong here?
Still trying to figure this one out. Any ideas? The only solution I have thought of is to capture the subcolliders to a set as they enter the trigger and do not act on entrances that belong to the same parent as another collider already in the set.
@Wip3ou7 Hmm, I am working my way through something similar, trying to setup head shot detection. I am seeing similar results. I have my model setup with the root object holding a capsule collider that I have sized up to the neck, and tagged "Flesh". The skeleton has a child sphere collider on the head bone (via RagDoll) that I have given the tag "HeadShot". I have my raycast script firing and if it hits a collider, it checks the tag. The tag returned is the root object. Things that I am about to try as I find time: 1) Use different layers for each collider, and filter the collision detection by layer. 2) Try setting the head shot collider to be trigger and use OnTriggerEnter instead of OnCollision for that use case. 3) Setup public GameObjects for each collider, drag-drop the collider component into each field. Detect via script. 4) Test collider type on collision. Capsule versus sphere. Take appropriate action based on results. If you beat me to it and find a solution that works, let me know what you did and I will try and replicate your success! Cheers, Mark