Search Unity

Collisions / Collision Detection Matrix / Nested GameObjects query

Discussion in 'Editor & General Support' started by Rob-Meade, Feb 28, 2019.

  1. Rob-Meade

    Rob-Meade

    Joined:
    Oct 27, 2016
    Posts:
    56
    Hi,

    I have a parent GameObject which contains multiple child GameObjects. All of the children are on one layer, the parent is set to another.

    When I run the game, projectiles from the player should only be able to be detected by the child GameObjects, however the parent GameObject is currently receiving these messages also, regardless of the settings in the Collision Detection Matrix.

    I have checked the GameObjects and prefabs in question and the layers are set correctly, the Collision Detection Matrix is also set correctly.

    The only way I seem to be able to prevent the parent GameObject from receiving the message is to disable, in the Collision Detection Matrix, the layer being used by the child GameObject, if I do this, no message is sent to the parent either. But, if it's enabled, the parent GameObject also receives the message.

    Any thoughts as to why I would receive messages for the collision in the parent object, is this message being bubbled up in some way?

    Whilst I can add some logic in the OnTriggerEnter2D method to effectively ignore it, I'd have liked the Collision Detection Matrix to have ignored it instead.