Yep, its happened to me and my sister before. It's very memorable because its so scary. 4 out of 10 people get it. Also, it runs in the family. Other factors include:
*lack of sleep
*sleep schedule changes
*sleeping on the back
So, as you can see, it can happen because of anything, even a leg cramp.
My last case went like this: I went to bed and was just falling asleep when suddenly, I remembered that Chucky movie I watched; it's about a doll that kills people when they're most vulnerable. Sleeping was a vulnerable position, and I had dolls in my room. So, I decided to stay up, but when I tried to get up, I couldn't move.
This is what happened; as I was falling asleep, my brain began to shut down my body. Everything was all set and my brain was ready to lose consciousness and fall into dreamland when I suddenly decided to keep my consciousness. By then, my body had been "shut down" so I couldn't move.
If I had stopped panicking, I would have noticed my brain sending me signals to make me sleepy so that I could give in and lose consciousness because my body was tired and wanted to go to sleep.
When I educated myself about this, the problem stopped. Whenever my body couldn't move, I didn't panic. In the end, I'd just lose consciousness and fall asleep.
I've also awoken before my body has awoken. The process is still the same. Don't panic. Your body will either make you go back to sleep or will wake the rest of your body up for you. It just takes a while. Of course, when you're scared, this feels like a long time. Still, calm down, and don't panic. Listen to your body.