Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Collision contact point outside collider?!

Discussion in 'Physics' started by GeriB, Aug 3, 2020.

  1. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Hi,

    While working on a fast racing car game I realised that the ContactPoints returned in the Collision paremter of OnCollisionStay are outisde the Box Collider of the vehicle.

    What's going on? It's physically impossible to have collision points outside the collider.

    The vehicle Rigidbody is using the much needed Continuous collision detection. It probably has something to do with it. How can you prevent this from happening? I expect to get the exact wall position
     
  2. DrViJ

    DrViJ

    Joined:
    Feb 9, 2013
    Posts:
    158
    Hi! Its not actually a collision, its a contact point between two colliders, and it appears before the real collision, and can exist after the real collision ended. The parameter Default Contact Offset influences the distance when contacts should be recognised.

    Unity Documentation: https://docs.unity3d.com/ScriptReference/Physics-defaultContactOffset.html

    And this parameter in settings:
    contact offset.PNG

    This parameter will change the distance when collision contacts will be created. And you can recognize the real collision when the impulse in contact is not zero length for example.
     
    GeriB and Edy like this.