That feeling you’re talking about is something called the Old Hag (among other things). Essentially what is happening is you’re beginning to fall asleep. Your body is locked in SP and you are beginning to go into a dream phase. When this happens and you are still conscious, your mind tries to come up with reasons for you not being able to move.
A lot of times it appears as a malevolent being looking over you or holding you down (a demon or witch is common). This is also usually accompanied by sounds and other lovely experiences. Now, since it is all in your mind, you can control this. I know a lot of people who have switched the image to something like a cute girl looking over them and other things. Just remember it’s based on your expectation.
Here, check out this link to the BIG sleep paralysis and old hag topic