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

The sprite itself behaving as a collider instead of an actual 2D collider.

Discussion in '2D' started by Kefiiir, Jul 7, 2022.

  1. Kefiiir

    Kefiiir

    Joined:
    Jun 5, 2019
    Posts:
    2
    Hello,

    I recently encountered this really strange issue when working on my 2D game. I tried to restrict player from going over the edge of the map by adding an invisible box - collider. For some reason when getting closer to that collider the player gets stuck into it, unable to move any direction. After further investigation it looks like the sprite itself is behaving as a collider - picture below. In the picture the player is already in the position that he cannot move left or right. But before it gets into this position the movement is working fine. Does someone know why this is happening?

    upload_2022-7-7_10-5-21.png

    I am using 2D character controller from Brackeys. Could that be causing the issue in the background?

    Also another question: why is there always a little gap when 2 colliders are touching (example from above - standing on the ground) and can this gap be adjusted somehow?

    Thank you very much for any help.
     
    Last edited: Jul 7, 2022
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    Verify the size of your colliders
    upload_2022-7-8_14-8-37.png

    Also, try moving the invisible wall to the other side of the player. Does that restrict movement as well? Move the wall further to the right. Does the player always get stuck the same distance away? Try making small adjustments and test to reduce the number of possible issues until you figure out what the issue is. I doubt it is a code thing, especially if you used a Brackey's tutorial, but if all of the editor changes dont work, then i suppose it could be code.
     
  3. Kefiiir

    Kefiiir

    Joined:
    Jun 5, 2019
    Posts:
    2
    I have just figured it out. Previously I defined the wall collider under the "Ground" layer so it was specified in the code under the IsGround section. This was for some reason causing the issue. But once I removed it from that layer it started working fine.

    Thanks for help anyways.