If all you have is your periscope. But the submarine sonar will track the ship miles before it gets into visual range and can target it without even using visual identification.
You might think so.
But, of two merchants and a destroyer and a carrier and an amphib, all 20 miles off but close to each other near the shore, how do you aim a torpedo at the right target?