Search Unity

Resolved Physics2DRaycaster component colliding with masked layers

Discussion in 'Physics' started by rell023, May 8, 2023.

  1. rell023

    rell023

    Joined:
    Mar 29, 2023
    Posts:
    20
    I have 2 colliders set up on each of my characters, one is a circle collider that signifies range and utilizes the collision enter event and is set to layer 7, the other is a box collider set to layer 9. The physics2draycaster component on the camera is set to mask layer 7, however the circle collider is blocking OnMouse and OnPointer events in its radius on all layers including 9, which I want to detect. Anyone have any clues as to why this would be happening? Thanks!
     
  2. rell023

    rell023

    Joined:
    Mar 29, 2023
    Posts:
    20
    Solved it. I had to set the layer the gameobject the physics2draycaster component was set to to not collide with the undesired layers in the layer matrix in project settings. The layer mask selection in the raycaster component is apparently useless
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    Just FYI: These "raycasters" are a UI feature and the OnMouse/OnPointer is a Camera feature and as such nobody on the physics team were involved in them. I only say this as asking questions about them is best asked elsewhere on the forum i.e. UI or Scripting sub-forums.
     
    rell023 likes this.