That's called lucid dreaming, when you lucid dream you can dream about anything, and control what happens, sometimes when you lucid dream before you go to bed you have to do a reality check, like poke yourself with a needle in the hand, just hard enough you feel it, and when you're dreaming you'll dream about poking that needle in your hand, and if it's successful the needle goes straight through your hand like it wasn't even there, and then you walk through a door and that's when you are in the lucid dream.