Media playback is unsupported on your device Media caption David Sneddon's artificial leg is connected by osseointegration, implanted into the bone.

Former soldier David Sneddon lost a leg after being shot in Afghanistan and has had a prosthetic limb for years. But pain and sores led him to a pioneering new method of attaching his artificial leg.

His prosthesis allowed David to kick a football about with his two sons and play golf but he was having increasing problems with his socket.

The traditional socket is made to fit on to the amputee's stump but even the best can slip and become uncomfortable or worse.

David, from Bathgate in West Lothian, is hoping a pioneering new method of fitting the prosthetic leg will give him better functionality, mobility and comfort.

Image caption The prosthetic is connected to a rod inserted into the bone

It is called osseointegration and involves a surgeon inserting a titanium rod implant directly into the bone of his amputated limb, before connecting it to his hi-tech prosthesis.

The idea is that the implanted socket allows the artificial limb to stay more firmly in place.

And because the implant is fused to the bone, patients can sense surfaces beneath the leg in a way that they cannot with a normal socket prosthesis.

David, 42, had the operation at the end of October, almost 10 years after being seriously injured by a bullet from a Taliban sniper while on a routine patrol in Afghanistan.

Image caption Former soldier David Sneddon loves to play golf but was having problems with his leg socket

He says he woke up two days later in Camp Bastion and was sent back to the UK for treatment.

"I had a bad infection in my femur," he told BBC Scotland's The Nine. "The bullet had missed my kneecap and hit my femur and shattered it completely. I'm grateful to be here, it could have been a lot worse.

"I think that's what keeps me going. Some lads weren't that lucky and never came back."

After two and a half years battling infection and enduring two failed knee replacements, he made the gut-wrenching decision to have his right leg amputated.

Since then he has been wearing a socket prosthetic.

Image caption David had to perform strengthening exercise after his operation

David says that when he first heard of osseointegration he thought it was not for him.

Just the thought of an implant going up through the bone was enough to put him off.

"But the opportunity came to me when I was having problems with my socket and I thought it was worthwhile looking at," he says.

While hip and knee implants are common operations, they are entirely inside the body.

Until recently it was considered potentially dangerous to break the skin permanently as it could be a possible pathway for infection.

Image caption David is building up his stamina with the new leg implant

It was thought very few amputees would even consider the risk of a protruding implant.

We visited David at his home just weeks after the operation as his recovery was just beginning.

His daily routine included hours of strengthening exercises and hospital appointments.

"I'm the third person in Scotland to get this done," he says.

"The two people before me are doing brilliantly so I am really excited for this. It's a bit scary as well but looking at the two lads who have had it done, they are doing amazing."

David was eventually given the state-of-the-art prosthetic in early December.

Image caption David Sneddon works at Kingsfield golf course near Linlithgow

The hi-tech limb includes a microprocessor knee which has six sensors that read the terrain he is walking on.

"When I am going downhill it will set a resistance in the knee so I can walk comfortably and when I am going uphill it will set a different resistance," he says. "It is constantly giving me feedback."

By the time we met him in January, David was down to using one crutch and trying to build up his stamina.

"Since my amputation in 2013 my muscles have been dormant," he says. "All my muscles have been stitched on to the bone and I can feel everything now which is giving me all these crazy aches and niggles.

"But I can feel when I'm walking on the carpet, when I'm walking outside, how soft the grass is, which is really good."

He still has a long journey ahead of him but David is now able to make plans for the future such as a family holiday to Florida and getting back to playing golf.

"The more confident I get with this leg and the more I get outside with it, I think, the happier I'll be," he adds.