Fixed raycasting bug when dir is 0