Search Unity

Collision glitch?

Discussion in 'Physics' started by FreeHugsHere, May 13, 2018.

  1. FreeHugsHere

    FreeHugsHere

    Joined:
    Apr 7, 2015
    Posts:
    9
    Im trying to do that my player can go behind the object and in front of it. The script i wrote is working and the render is working correct too, but in some point when the player come very close to the object collision in a dense and still walking, and after immediately go behind the object, render shows that the player is on the front of object.
    However if i don't touch this collision on the bottom of the object, everything work fine. I double checked the script, and its seems the problem because of the collision.
    Layers is in the right orders.

    The character have rigid body2d, collider 2d, and the child object with the script that helps to sort layers have also collider 2d.
    Object(The Stone) have polygon collider 2d and the child - box collider 2d which i assume is cause this glitch, but i need it also so player can't go through the object, so it looks not like i want.



    Any ideas how to fix it?
    Thanks.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    It has to be in the logic of your script (perhaps in a collision callback), collision has no impact on rendering.