Search Unity

Detect adjacent collision

Discussion in 'Scripting' started by Givago, Apr 3, 2017.

  1. Givago

    Givago

    Joined:
    Oct 22, 2015
    Posts:
    27
    I'm trying to figure out if in the next position in 2D I'll have a collision "via script".

    I tried using:
    Overlapbox, take my position.

    But I did not understand how to do it,

    Does anyone have any ideas?
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Could you post your code? Overlapbox sounds fitting as an option. There are other variations of that you might consider depending on your situation, but since you haven't got it working at all, better to start small :)
    You want to input the position and size and test your result.
     
  3. Givago

    Givago

    Joined:
    Oct 22, 2015
    Posts:
    27
    It just did not work.
    I'm trying to find some method that works.

    I just want to check if the next tile has a floor to walk on.
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    It's easier, if you have a follow-up question, if you post some code you've tried. For instance, if you used one of the overloads that only returns one hit and your size/position was bad, perhaps you got a result, but not for your next tile.. or something else (any number of other results).