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. Dismiss Notice

Bug character randomly jjumps / stumbles on flat surface

Discussion in '2D' started by UwUErika, Aug 18, 2023.

  1. UwUErika

    UwUErika

    Joined:
    Jun 1, 2023
    Posts:
    1
    I'm making 2d nnsg game but from start I have this problem where when my character is running on flat surface he randomly jumps a little . It's definitely not problem with movement script . I assume it has to do something with how unity's rigid body 2d interacts with tilemap collider 2d or tilemap effector 2d but I just can't figure it out. I've spent multiple hours trying to figure it out with chatgpt and phind but wasn't able to resolve the issue (google didn't help either). These are the settings on my ground upload_2023-8-18_14-34-44.png
    and here is screenshot of player rigid body + boxcollider settings upload_2023-8-18_14-36-4.png
    any and all help will be appreciated :>
     
  2. Dedi6

    Dedi6

    Joined:
    Jan 20, 2019
    Posts:
    119
    I haven't touched Tilemaps in a while BUT I have 2 solutions for you:

    - The first one I want you to test and think if it fits your game - use capsule collider 2D on your player.
    I wish I had done this in retrospect. I use some platforms which aren't in the tilemap, and any slight change in the Y axis can cause the box collider to get stuck on it. (HATE THIS)

    - Usually you'd want to use composite collider on your tilemaps, and check the "use composite collider" on the tilemap collider. That will combine the individual colliders.

    Good luck!~