Lucid dream
In a lucid dream a person becomes aware that they are dreaming while the experience continues. How much influence they have over the scene is a separate question.
Example
In a laboratory, some participants responded from verified REM sleep with agreed eye movements. This allowed individual responses to be matched to the sleep recording.
Read more
Source
Konkoly et al. · Real-time dialogue during REM sleep