Search Unity

Random raycast/sweepTest failure

Discussion in 'Physics' started by Issam, Feb 15, 2015.

  1. Issam

    Issam

    Joined:
    Dec 18, 2012
    Posts:
    37
    I am quite sure that sometime a raycast or a sweeptest will randomly fail at detecting a collision. We are using mesh colliders for the environment so I am wondering if it might be related to that. Did anyone notice something like this? Any idea why it might be happening?
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If you do a raycast or sweep test against *moving colliders* then the collider positions will only update at the next fixedupdate. In between this time, it's perfectly possible your raycasts or sweeps will miss.

    Otherwise its quite likely it's your code.