## 4 Proposed Framework to Improve the Sense of Agency in Immersive Virtual Environments  
Relevant frameworks are studied in Section 3.7, most of them focused on enhancing the sense of presence [114] and immersion [115] or on managing the emotional interactive flow [112]. However, in this work, we are focused on improving and evaluating the sense of agency in virtual environments. Some virtual environments employ techniques for emotion recognition: facial expressions [117] and modules to capture and analyse real-time physiological data during VR interactions [114,116]. Others, such as [119], highlight the importance of developing frameworks based on appraisal to manage cognitive models, which may be useful for managing intention when addressing the SoA. Also, other research, such as [97,120,122], suggests that the sense of agency can be improved by adapting the virtual environment to the users' body movements. Since the sense of agency has a significant impact on our daily lives, in this section we propose a framework which integrates the key elements of the interactive flow within an IVE. We also address the technologies needed to manage its emotions, focusing on enhancing the user's sense of agency. The theoretical basis of this framework relies on the definition of agency described in [14], which states that the SoA is composed of two layers (Figure 2). As explained in Section 2.4, the first layer addresses the sense of agency over one's own action (body agency), and the second layer presents it over external events (external agency). Although the literature in the field of psychology does not always draw the line between these two layers, this model is selected because its clear structure is more suited for implementation. Moreover, its design is particularly applicable in the context of immersive virtual environments, because it moves far beyond body agency, and it includes external agency, which is essential for evaluating interaction in an IVE. The two-layer model links the SoA not only with a virtual avatar but also with the coherent response of the environment, involving different senses, such as sight, hearing and touch (Figure 7). This work is based on already existing Affective Computing technologies that can be used on both layers to implement a complete method that improves the SoA for body and external agencies. In fact, AC offers tools to develop closed-loop interactions to improve the SoA by managing emotions. Specifically, AC provides applicable models that could be used to predict intention, as well as systems to generate coherent emotional responses to that intention. In addition, AC technologies allow the evaluation of the SoA through metrics such as anxiety variations or detection of users' perceived errors during interaction. The proposed framework shows the main elements involved in closed-loop interaction in immersive virtual environments: the users and their virtual avatars, the environment itself, and the interaction that could happen between them. This interaction flow is shown in Figure 8. Dashed lines indicate the transmission of sensations or emotions and continuous lines indicate the coupling of two elements, implying direct interaction between them. Each element groups the technologies that we propose in order to manage the necessity of recognising, expressing and generating emotions depending on a given situation. Each of these interactive elements generates events and responses that could influence the sense of agency of the users involved in the interaction. This framework aims to integrate the technologies related to the AC field that allow interpreting the intention and emotional state of the user, to generate a response from the IVE that fulfills their expectations following the theory of the two-layer model which integrates body and external agencies.