Chances are you spend too much time looking at the obstacles, and not enough time looking ahead.
By all means, you need to spot the rocks and roots that you wish to avoid. But don't watch them; you'll unconsciously bike toward whatever you're looking at. Instead, look ahead at the route that you want to follow.