This used to happen to me a lot when I was a kid, back when I was LDing before knowing what LDing really was.

Most of the times that I'd wake up with a wet bed, I'd remember having pissed in a dream. It got to where if I had to piss in a dream, I would immediately becomg lucid, telling myself "NOOOOO NOOOO!! I GOTTA WAKE UP!!!!" and I would wake up, and save myself from having an accident.