Search Unity

Question How to detect overlap area of 2D sprites?

Discussion in '2D' started by nathanh635, Mar 22, 2023.

  1. nathanh635

    nathanh635

    Joined:
    Oct 23, 2022
    Posts:
    2
    Hi. I'm pretty new to unity, and I'm trying to make a simple 2d cleaning simulator, that has different shape cleaning tools following the mouse pointer, and when you click, it cleans the 2d sprite where the sprites overlap.

    I have a collider on my "floor" area, and I am able to detect mouse clicks within the collider. I've looked everywhere online, and can't seem to find a way to get the area of the overlap between the two sprite layers, and then either remove or add something at the overlap area (i.e., either clean the dirt or add soap, etc). Does anyone know a way to get the area of the overlap, either partial or full?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,744
    nathanh635, Chubzdoomer and MelvMay like this.
  3. nathanh635

    nathanh635

    Joined:
    Oct 23, 2022
    Posts:
    2