Welcome aboard !
The link provided is already a good lead, however how much do you know about the attack - are you playing "full real" using game modifications, or is it the basic SH5 sim ?
Generally it is about lining up the boat, ideally at an angle of 90 degrees to the course of the ship you want to sink.
You generally need the distance of the ship to you, the course of the ship and the "angle on the bow", to enter into your then mechanic-electrical "torpedo data computer".
Good luck and don't hesitate to ask