Search Unity

[Solved]Wrong hit on far-away collider using Physics.Raycast?

Discussion in 'Physics' started by Immanuel-Scholz, Jul 10, 2015.

  1. Immanuel-Scholz

    Immanuel-Scholz

    Joined:
    Jun 8, 2013
    Posts:
    221
    Hi,

    I am currently investigating a very rare and strange bug. I nailed it down to a suspicious result from a Physics.Raycast.

    I've got a ray at location 396, 200, 360.1 that points straight downwards:



    Then I do my raycast using "Physics.Raycast(ray, out hit, 1000.0f, someLayerMask)"

    And I got a hit, horay. The point of impact and distance and everything looks okish. Same X/Z position, in height 3.3 and the distance is about 200-3.3 = 196.7



    However, there is no collider at this point. The reported collider that is supposed to be hit (skull_coll) is over 40m away at 397.6, 2.3, 359.7 and its extend is very small (only 4.4, 2.3, 3.4).



    Anyone got any idea what might happen here and what could cause this and how I could precede? The error really only shows up very very seldom..
     
  2. Immanuel-Scholz

    Immanuel-Scholz

    Joined:
    Jun 8, 2013
    Posts:
    221
    Man, I am so blind right now.. As you all probably spotted immediately, I confused 360 with 320 (another collider).

    Damn, *blush*

    Thank you all, and please continue walking. There is nothing to see here...
     
    chelnok likes this.