It sounds like you were entering sleep paralysis.

It's nothing to be afraid of- your body naturally does this every night as you're falling asleep. We're just usually unconscious when it happens.