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

Question Player bumping when moving across platforms of the same height

Discussion in 'Physics' started by JaxNovawind, Sep 6, 2023.

  1. JaxNovawind

    JaxNovawind

    Joined:
    Sep 2, 2023
    Posts:
    3
    This is my first time with game development, so I'm really just testing things out here. Part of it was I designed this set of platforms: Unity Problem.png
    (I marked the middle one blue to make explaining easier)
    However, when moving the player capsule from the teal one to the blue one, it occasionally has a small bump like so:


    Clearly, something is wrong with colliders but I'm not sure exactly what it is or how to fix it. I've looked up potential solutions, and the only one I could find that likely works is honestly way too complicated for my minimal experience.

    Possible reasons why this is happening:
    1. When looking at the platforms, I can see the edges are overlapping back and forth. This could mean the colliders are overlapping as well and creating issues.
    2. When testing this out, I notice that, when jumping to the next platform, if I just barely land short, the capsule collides and is sort of bounced back up onto the platform. This is probably a normal property of Unity, but it could be interfering here.
    3. The capsule is directly colliding with the floor when it moves. I read about a way to make your capsule float using some complicated coding, and this usually prevents collision issues, but I'm not equipped enough to know how to do that.

    So, should I:
    1. Find a way to fix this problem
    Or 2. Delete the blue platform and wait until I have more Unity and C# experience to tackle a problem like this.
     
  2. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    70
    are you 100% sure they're properly aligned?

    I would recommend against sticking environment colliders into each other haphazardly as in my experience unity gets mad

    you could also go another route such as meshcolliders if your levels are the majority of collisions and similarly simple
     
  3. JaxNovawind

    JaxNovawind

    Joined:
    Sep 2, 2023
    Posts:
    3
    All three platforms have the same Y-Coordinate down to 4 decimals.
    I haven't ever touched meshcolliders (at least not to my knowledge), so that could potentially fix it.
    As for the "game" itself, it's not even really a game. It's basically just "can I make a player move across platforms, kill enemies, and collect items"?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    This affects all physics system and isn't a Unity specific thing.

    Multiple Colliders, no matter how "well aligned", are not a continuous surface so the solver might detect the edges/faces as you transition causing a collision normal that isn't tangent to the movement direction.

    I'm not a 3D physics dev but a 2D one and in that system, only a single collider shape type supports this (Edge). In 3D you can minimize the effect of a non-tangental normal by using a CapsuleCollider (better than a BoxCollider) but not remove it as you've seen. An alternative is to register for contacts and modify them; something which is available in 3D physics.

    You can find more information about this if you search "Ghost Collisions" or "Ghost Vertices" etc.

    There's also this talk that discusses it more for 3D:


    And this for 2D physics: https://www.iforce2d.net/b2dtut/ghost-vertices
     
  5. JaxNovawind

    JaxNovawind

    Joined:
    Sep 2, 2023
    Posts:
    3
    Sorry it took so long to reply (being a Chemistry major is a lot).
    I checked my project, and the box for CapsuleCollider is checked, so if it's turned off, I'm not sure how and where.
    I looked around at Ghost Collisions and Ghost Vertices, but I really did not know where to start with that, at least not until I have much more programming experience.
    So, I might just remove the blue platform and continue slowly working my way up.