My opportunity cost for going to med school (residency included) vs. staying in my previous career is right at a cool million. Lots of money. Even so, there are many many areas in medicine where that opportunity cost can be repaid in around five years, some less, even granting my previous career the typical salary increases from raises, promotions, and job swapping (I figured two in the 7-9 year med school journey), which in total would have added around 50K to my salary at the time I entered med school. So for me at least, it's a break even proposition at about 15 years out. With another 25 or so productive years beyond that, the comparison isn't even close.
Now, the above isn't the case if you look at FP, IM, peds, etc. You have to be realistic going in about where your interests truly lie, and make an honest assessment of your potential. Fortunately for me and many others, there are dozens of fields within medicine that are extremely interesting to me, were so at the outset, and pay plenty well enough for me to not have great concerns about shooting myself in the foot. I didn't enter medicine to get rich, but I wouldn't have made the move if I though it would be financial suicide.
And my analysis assumes the longest residency, no moonlighting, no debt forgiveness or other types of bonuses after residency completion, below starting salaries in many fields, absolutely no physician reimbursement increases for the next forty years, and some very favorable assumptions about my previous career.
Unless you are already making more than 100K in your current career and/or have significant potential for serious raises, or you have a pretty solid career and your calling is peds, you probably won't come out behind after switching to medicine. Sure, it may take you a while to pass that 60/hr plumber, but it will happen. Just be realistic about the timeline involved.
Besides, as I've pointed out, you can open doors anywhere you go. As an engineer, there were always going to be opportunities to venture into the world of business and entrepreneurship, but those doors won't close just because I've done somewhat of a U-turn.
In fact, I may find that there are now doors open for medical ventures, engineering ventures, and combinations of the two that many other people may not have. Not to mention that I'll eventually have greater liquid capital with which to pursue them, and much much greater fundraising ability a bit sooner than "eventually."
Most of all, I'll enjoy the job more, regardless of the paycheck, which is ultimately the bottom line. If I don't net one penny more in my lifetime, I'll still be one happy SOB. Being able to provide more for my family along the way would be a nice bonus.