An RAF serviceman accused of raping a 15-year-old girl claimed he was sleepwalking and "remembers nothing" about the incident, a court heard.
Kenneth Ecott, 26, had been at the Royal British Legion club in Poole, Dorset, celebrating a birthday, before the party moved to a friend's house.
The court heard he went to sleep with other people - including the alleged victim - on mattresses on 19 November.
Mr Ecott denied one count of rape at Bournemouth Crown Court on Thursday.
The trial heard he shared a bottle of vodka with others at the party and then fell asleep on inflatable mattresses in the dining room.
The girl, who cannot be named for legal reasons, woke in the early hours of the morning to find the Senior Aircraftman naked on top of her and started screaming, the court heard.
Mr Ecott told police during an interview he could not remember anything between falling asleep and finding himself naked on the street.
The court heard other people at the party told him "he had sex with the teenager".
He told the court: "It was like being shot in the chest. I couldn't believe what I had just heard."
Mr Ecott was arrested at his barracks in RAF Brize Norton, Oxfordshire, later on the day of the alleged incident.
He told detectives in Poole he had been sleepwalking and was "not aware of his actions as he had been in a state of automatism".
The court heard he said during an interview: "I laid down to go to sleep.
"The next thing I knew I was stood outside completely naked in the middle of the street wondering what the hell I was doing there."
Mr Ecott's father was killed in an incident when he was 12 and his mother died of cancer five years later, the court heard.
The jury also heard he suffered "night terrors" and had once punched his girlfriend during a bad dream, but had no recollection of it afterwards.
Mr Ecott joined the RAF in June 2004 and worked as a telecommunications operator maintainer, responsible for running IT services in air force and army bases.
He served for four months in Iraq and then went to Afghanistan for three months to run the IT services at a base in Kandahar.
The court heard he was not sleeping properly because of jet lag on returning from Afghanistan on 16 November, days before the party.
The case was adjourned until Friday.