Hello Dakuliu: From what you describe, it sounds to me as though you experienced what is called: "sleep paralysis". I don't have this anymore (thank god!) But when I was younger (I'm a "senior citizen" now) I used to have episodes such as these regularly. And you're correct. They are terrifying! For many years I had no idea what was going on. It was only toward the end of that period of time when I was having these episodes that I finally stumbled onto an explanation of them.
How I coped with them, was I used to focus all my attention on simply moving one finger. Then, when I could move one finger, I'd expand my focus to the rest of the fingers on that hand. Typically, at that point, I would snap back into full waking consciousness & the paralysis would disappear. I'm including a link to a Web MD article on sleep paralysis for you to look at. Hope this is helpful!
Sleep Paralysis Symptoms, Treatment, and Causes