It seems as if it isn’t possible to raycast against colliders
that has been moved earlier in the frame? I have created a
test project, download it here (turn on gizmos!).
There’s two cubes in the scene. The first one is in the imminent
raycast’s path, while the second is not. In Update() I move the
first cube out of the way, the second cube is moved into the
raycast’s path. I perform the raycasts and move the cubes back to
their original positions.
The point was that I have had some strange behaviors when it comes
to raycasting so I wanted to find out if Unity uses the current position
of colliders or if it possibly only updates colliders at the end of the frame.
Turn out it doesn’t hit either cube.
Is this intended behavior? Then it should probably be documented (maybe it is?),
as the effect can be pretty serious (all enemies should be moved after you have
done your raycasting). Has anyone else run into this problem?