Search Unity

How to prevent ghost collisions without DOTS?

Discussion in 'Physics' started by lowhearted, Jun 7, 2020.

  1. lowhearted

    lowhearted

    Joined:
    Jan 3, 2018
    Posts:
    5
    The player collider is stuck on the seam! This happens on floor seams, wall seams, etc. Whenever the player collider walks on two adjacent colliders, it gets stuck on the seam!

    Here is a simplified example of what I'm trying to do. In this picture, if I move the player forward, it collides with the seam between adjacent colliders.
    So what's the solution? Using Havok Physics with Unity DOTS, you can avoid these ghost collisions. Unity's physics implementation is very weak (without DOTS) and offers no direct solution to this problem. Combining adjacent colliders, playing with physics materials, changing collision detection, and various other methods don't solve it either.

    Is there any way to avoid these ghost collisions without using DOTS?
     
  2. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    Is it just a matter of the corner of your collider getting stuck on the corner of the ground collider?
     
  3. lowhearted

    lowhearted

    Joined:
    Jan 3, 2018
    Posts:
    5
    Yes. The box collider collides with the edges of the floor collider. I can use a capsule collider, and there won't be a problem in the situation above, but there are still other clipping problems. They aren't readily apparent-- point is, no matter what collider I use, this problem occurs. The only way around it that I know is to use Havok physics with DOTS.
     
  4. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    I can honestly say I've never had this because I use a capsule collider on things that are not precisely square. I'm guessing that gap between the cubes is never going to precisely make a flat surface (although I would have thought it should).
     
  5. lowhearted

    lowhearted

    Joined:
    Jan 3, 2018
    Posts:
    5
    There is no gap... Also, this problem will come up with capsule colliders if you're falling while rubbing a surface with the same conditions.

    It's just pathetic that I need to migrate my entire controller to DOTS to fix this problem. Problems like this make me want to move to unreal. The API for physics is just so weak.
     
  6. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    Believe me, unreal does the same. It’s not great but that’s just games physics, floating point precision etc. - if it didn’t do that, the whole physics system is compromised.
     
  7. lowhearted

    lowhearted

    Joined:
    Jan 3, 2018
    Posts:
    5
    If Unity3d allowed us to prevent a specific collision, this whole problem would be solved. Currently, we can only block collisions between certain layers and objects.

    This way, I can look at an individual collision, determine if it is a ghost collision, and disable it that way.

    As for Unreal, this problem does have a much simpler solution. There were a lot of indie titles from Unreal that don't have this issue-- both engines have solutions, but Unity3d wants us to migrate our controllers to DOTS for Havok physics to fix this.
     
  8. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    989
    You can disable specific collisions via scripting.
    https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html
     
  9. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    989
    But yeah, as davidnibi said, this is a very common thing in most collision systems. You just have to design around it. If you're not interested in using a capsule collider then it might be worth considering using bevels on your floor/wall pieces. Still not perfect but it might help in most cases.
     
  10. lowhearted

    lowhearted

    Joined:
    Jan 3, 2018
    Posts:
    5
    No, this disables all collisions between two colliders. I want to ignore a specific collision. In other words, I want to be able to look at all collisions in OnCollisionEnter() and disables ones I would consider ghost collisions.

    If Unity3d could implement this, this would meliorate so many problems I have with their physics implementation. I would just use DOTS, but no current networking kit even supports dots (Mirror, UNet, Photon, etc).

    Unity's networking kit will probably come out Q2 2021, and it would suck if I'd have to wait that long to fix such a simple problem.