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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Check if a certain gameobject is inside a collider

Discussion in '2D' started by xliquid, Jul 5, 2020.

  1. xliquid

    xliquid

    Joined:
    Jan 29, 2020
    Posts:
    6
    I want to check if a game object with the tag cube is inside a circle collider which is around the player. I want to use this for spawning cubes, but I only want to spawn cubes when the player is not surrounded by one.
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
  3. xliquid

    xliquid

    Joined:
    Jan 29, 2020
    Posts:
    6
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    The above callbacks are for 3D physics only so won't work at all for 2D colliders. You should use the ones with the 2D suffix i.e. OnTriggerEnter2D etc.