Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

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:
    33,691
    nathanh635, Chubzdoomer and MelvMay like this.
  3. nathanh635

    nathanh635

    Joined:
    Oct 23, 2022
    Posts:
    2