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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D Collision Issue!

Discussion in '2D' started by SP-Designs, Jan 18, 2016.

  1. SP-Designs

    SP-Designs

    Joined:
    Oct 13, 2015
    Posts:
    184
    Hello! I am making a 2d game and i have a character with a polugoncollider2D and the ground tiles(each one has a boxcollider2D)! My problem is that, although the ground tiles's colliders are all at the same height, my player sometimes gets stuck on them and cannot move forward(so i have to either jump or move back and go forth again).Do you know why this happens?

    Here are some images of my player's collider and the ground tiles's colliders :

    Unity 2016-01-18 22-15-09-32.png

    *[Edited] 19/1/16 : The problem has been solved thanks to the great community.If anyone else is having the same problem visit this website and follow the tutorial as it is,it will work great!

    Website for 2D collision problems : http://johnstejskal.com/wp/setting-up-your-characters-2d-colliders-in-unity/
     
    Last edited: Jan 19, 2016
  2. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    I'd say it's PolygonCollider's small bulges somehow stop at box colliders. Why not try BoxCollider for player too? I doubt you'll lose much with that.
     
  3. SP-Designs

    SP-Designs

    Joined:
    Oct 13, 2015
    Posts:
    184
    Nope nothing.Btw i have another small boxcollider2d on his legs so that i can check if he is grounded, i do not know if that could cause such a problem!
     
  4. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
  5. SP-Designs

    SP-Designs

    Joined:
    Oct 13, 2015
    Posts:
    184
  6. funshark

    funshark

    Joined:
    Mar 24, 2009
    Posts:
    225
    Don't use box but line.
    The vertical lines coming with the boxes can stop box/mesh colliders because of a lack of precision in values.
    You can try with a circle collider on your character though ( but definitely don't use a mesh collider unless it's strictly necessary )
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
  8. SP-Designs

    SP-Designs

    Joined:
    Oct 13, 2015
    Posts:
    184
  9. MoonJellyGames

    MoonJellyGames

    Joined:
    Oct 2, 2014
    Posts:
    324
    I had a set-up like this at one point but I ultimately decided that it was not a good solution. The part of the circle collider that sticks out of the bottom will still occasionally get snagged on tiles, particularly if your player is falling and happens to land in just the right position. Also, when you have your player standing at a ledge (so that they are grounded with the box collider) and then you move towards the ledge, there is a noticeable bump when the circle collider hits the ground.

    Maybe these things aren't an issue for you in your game, but I would still highly recommend trying out a raycasting approach instead.
     
  10. ToyBrain101

    ToyBrain101

    Joined:
    Sep 15, 2014
    Posts:
    13
    you should look into raycasting. go easy on the box colliders they stick out
     
    MoonJellyGames likes this.