In unity3d, colliders are updated only after the FixedUpdate()
method runs, so that might be why your objects aren't being hit by the raycast.
It's usually better to keep all transformations of gameObjects with colliders in FixedUpdate()
, that way the raycast should work as expected.
For starters simply try moving the code you mentioned in your question from the Update()
method to the FixedUpdate()
method (If you don't have one, simply create one).