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. Dismiss Notice

How to ignore background ontriggerenter2d

Discussion in 'Scripting' started by nicklowkc1, Jan 30, 2021.

  1. nicklowkc1

    nicklowkc1

    Joined:
    Feb 27, 2019
    Posts:
    28
    I have a background sprite that has a boxcollider2d attach to it. When the game starts, it will spawn a circle with circle collider2d attach on the background. If the circle is overlapping the background, what can I do to ignore the background collision if I am touching the circle? I am not using Raycast2d, just simple ontriggerenter2d because I am doing something like slashing.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Using layers, you can make certain collisions and triggers ignore each other.

    Look in Edit -> ProjectSettings -> Physics2D ... there's a big grid of layers and who interacts with who.
     
  3. nicklowkc1

    nicklowkc1

    Joined:
    Feb 27, 2019
    Posts:
    28
    But what if I want to detect touch on background if there is no circle exist. Simply speaking its a little bit like which part will be collided first..