Search Unity

Help with 2d Collision (video)

Discussion in '2D' started by fosmark13, Sep 3, 2016.

  1. fosmark13

    fosmark13

    Joined:
    Feb 16, 2015
    Posts:
    91
    Hi everybody, my current problem with the collision and that i just can't fix it yet is that my player goes trough the ground colliders that i have. the problem is even bigger when is jumping form one platform to another because every time he lands in almost the edge of the platform he goes trough it and falls down, and this kind of behaviour is not good for a platformer game so i put a video where you can see what is happening.





    some info about the player is that i have 2 checks that draw a straight line from left to right to check if the player is touching ground and the player only has a box collider 2d attached to it. i found dome info saying that this is for ths physics engine and it's because the high speed but my player's speed is very slow to do this kind of thing, its collision is on Continuos as well...

    any help would be great
    thanks!!!
     
  2. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    I can't say for certain but it looks like the code for him catching the edge of the platform might be the issue. I noticed when he jumped left he landed on the edge of the cliff and grabbed it. Also when he fell off the edge of the platform and was facing right.. he grabbed it. but falling off the edge facing right (on the left side) he just kept falling.
    Does your grab the edge code care about direction facing?

    He's clearly not falling though in the middle of the platform, so this is just an "edge" case scenario. Some code is thinking he's too close to the edge and making him fall. I don't think it has to do with him not "hitting the ground" Otherwise you'd see the issue happen in the middle of the platform.
     
  3. fosmark13

    fosmark13

    Joined:
    Feb 16, 2015
    Posts:
    91
    Hi, yes the player grabs to the wall depending of his direction, he falls because he was not facing right and the platform was to the right, besides that i don't have any specific code to check the edges of the platform or the ground... And that happens too in the middle, the diference is that there can't go to the right or left so he goes up and in the edges can.
     
  4. dworm

    dworm

    Joined:
    Jun 17, 2015
    Posts:
    74
    Post the grab the wall part of the code, probably there is the bug.
     
  5. fosmark13

    fosmark13

    Joined:
    Feb 16, 2015
    Posts:
    91
    hi sorry for the late, i just figured out that the problem was caused by the collider... i change its size when the player jumps, i make it smaller, so when the collider touches ground it goes back to its original size and in that process is when the player moves to the edge cause the other collider(the platform) don't allow it to go through it. anyway it's already solved... thanks for your answers!!!!