Search Unity

Question Collision exit contact point?

Discussion in 'Physics' started by wechat_os_Qy0wHuvKoHrB5pwwCiKyHaupA, Dec 5, 2023.

  1. wechat_os_Qy0wHuvKoHrB5pwwCiKyHaupA

    wechat_os_Qy0wHuvKoHrB5pwwCiKyHaupA

    Joined:
    Aug 20, 2022
    Posts:
    6
    I want to get the position of collider hit and exit. I know I can get the hit position by using Collision.getcontact(), but can I get the exit position (the last position where two colliders hit before they are not contact to each other)?
     
  2. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    275
    either use oncollisionexit, or you cache the result of .getcontact for later and then use the last valid value when the result returns null.
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    Exit collision happens when there are no contact points, it's impossible to tell you what the contact point(s) are if there are none. The last point provided would be in Enter or Stay.

    If you need to know that information then you need to store that information.