Episodic memory encoding is highly influenced by the availability of attentional resources. Mind wandering corresponds to a shift of attention toward task-unrelated thoughts. Few studies, however, have tested this link between memory encoding and mind wandering. The goal of the present work was to systematically investigate the influence of mind wandering during encoding on episodic memory performances in an ecological setting. Fifty-two participants were asked to navigate in a virtual urban environment. During the walk, they encountered different scenes that, unbeknownst to the participants, were target items presented in a subsequent recognition task associated with a Remember–Know–Guess paradigm. Each item triggered, after a random interval, a thought probe assessing current mind wandering. We found a significant linear positive relationship between the ratio of correctly recognized items and the overall mind wandering reported after the task. Moreover, we found a quadratic reversed U-shaped relationship between the probability of giving a ‘Remember’ response and both on-line and mind wandering reported a posteriori. The nearer to the medium value the level of mind wandering was, the higher was the probability to have a recollection-based recognition. Our results indicate that in a complex environment, the highest probability of actually remembering a scene would be when participants present a medium attentional level: neither distracted by inner thoughts nor too focused on the environment. This open attentional state would allow a better global processing of the environment by preventing one’s attention from being captured by internal thoughts or narrowed by an over-focusing on the environment.