Search Unity

  1. Unity 2019.4 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Objects don't come in contact.

Discussion in '2D' started by Akenaten, May 20, 2020.

  1. Akenaten

    Akenaten

    Joined:
    Apr 3, 2020
    Posts:
    2
    wtf.png

    Blue Object (Player) has a Rigidbody2D / Collider2D / Script components.
    Orange Object ( Grounf) has Collider2D component.

    After hitting play the player begins to fall and stabilizes at that height. The box colliders are not in contact with one another. When i pull the player any closer to the ground and let go of the mouse, it appears as if a force pushes it back to that height.

    What is going on?
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    729
    How far are you zoomed in? There is a Default Contact Offset in the Physics2D settings that you could play around with to get them closer, but I would advise making the box colliders slightly smaller to compensate for this.

    I had an issue with this awhile back with a pixel art game that had "large" gaps between objects and triggers being triggered when they shouldn't have been. In the end I set the offset smaller to match the pixel art and played with the colliders so it would appear that they were touching.
     
    Akenaten and MelvMay like this.
  3. Akenaten

    Akenaten

    Joined:
    Apr 3, 2020
    Posts:
    2
    I am not sure how to check the zoom level (doesn't seem to indicate it anywhere) but i will try messing with the colliders first. Thanks for the heads up though.
    Did you complete your game?
     
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,020
    @Akenaten

    "I am not sure how to check the zoom level"

    I think by zoom level @Chris-Trueman meant you only show corners of two rectangles, you could be infinitely close to that corner area... as we don't see full rectangles. And because you are working with physics system it is has to work in some scale I guess, so if you have set your contact offset to some specific value, it would not look the same with objects 100x smaller or bigger.
     
    Chris-Trueman and Akenaten like this.
  5. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    729
    This is exactly what I meant.

    No its still a work in progress. I put it on the back burner so I could figure out some issues with inventory and items, never got back to it. Now my artist wants to change the graphics from pixel art and also change how some of the mechanics work. One day maybe I'll finish a game.
     
unityunity