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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

annoying small collision when walking on box colliders that are mean't to be flat

Discussion in 'Scripting' started by nicolas Jullien, May 22, 2013.

  1. nicolas Jullien

    nicolas Jullien

    Joined:
    May 13, 2013
    Posts:
    3
    Hello everyone!

    As I say in my very accurate post title,
    I'm having a nice little character running pretty fast on a box collider, everything is going very fine
    The thing is more box colliders are added randomly after the first one so the character can keep running and not fall.
    All the boxes are the same size and have the same y position so there is no gap whatsoever between them.
    Unfortunately once in a while and I can't manage to know why, the character bumps into the junction (that doesn't exist since there's no gap) between two boxes...


    I'm sure this is a common problem but I can't find any answer on the forum...
    Hope you can save my life
    nico
     
  2. DougMcFarlane

    DougMcFarlane

    Joined:
    Apr 25, 2009
    Posts:
    197
    I have this exact same issue with a 2.5d side view golf prototype I attempted.
    Here's a web player demo to see this issue:
    https://dl.dropboxusercontent.com/u/1979274/CubeGolf/WebPlayer.html

    If you roll the ball along the bottom (ball moves in direction you click), it will periodically jump into the air, where the colliders meet. Each 5x5 unit level chunk has a mesh collider, and meshes are dynamically generated at runtime via a Tiled level editor file.

    For your case, you could modify the first box collider to extend it to include the new area. Good only if the floor has no slopes. And bring the start of the box collider forward when off screen to prevent very large colliders.

    I don't know the reason however. The physics engine just thinks the two adjacent colliders are not smoothly aligned, even though they share the same y location. Floating point error?
     
    Last edited: Dec 21, 2015
  3. nicolas Jullien

    nicolas Jullien

    Joined:
    May 13, 2013
    Posts:
    3
    Yeah that's the same problem, annoying!
    I can't do the collider trick since I'll need to have slopes yeah... Not sure where to look, I've played with the rigidbody, colliders and material options without success...
     
  4. -JoSeM-

    -JoSeM-

    Joined:
    Jul 8, 2014
    Posts:
    9
    I am interested on this also, i have thesame problems on unity 5.3.1........
     
  5. hexagonius

    hexagonius

    Joined:
    Mar 26, 2013
    Posts:
    98
  6. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    What if it's a 3D box collider? Nothing like a 2D edge collider only in 3D, no? I'm trying to tile up chunks of a straight road and my cars sometimes gets "stuck" between the chunks. I'm not even doing that programatically.
     
  7. hexagonius

    hexagonius

    Joined:
    Mar 26, 2013
    Posts:
    98
    As long as it's corners against corners, there is no reason why it should be any different. But a car has wheel colliders or spherical wheels doesn't it?
    in the worst case you probably should be generating MeshColliders that fit the road by code. that would be the equivalent to the EdgeCollider2D.