Keeping the mouse within the viewport

Hi,

I’m currently working on an educational game and porting it to PC from mobile. It’s a first person adventure game where the player controls the camera via the mouse, where the mouse cursor seems locked to the viewport which is what I want. The problem I’m currently facing is that while I can rotate the camera using the mouse, if I click within the viewport, I can then move my mouse cursor outside of the viewport, which causes issues for my camera rotation (e.g. when I click back into the viewport, I lose my ability to rotate the camera). I’m currently using the “Set input mode game only” node in my player controller, which I thought would lock the cursor in the viewport.

Any help would be appreciated, thanks.

on begin play, get player controller and from that, set game mode game only. That should solve the problem :slight_smile:

Comment below if there are still issues, and if this solves it, please accept the answer. Thanks :slight_smile:

Thanks for answering, however unfortunately I believe this is what I’m already doing.

Below is the set of nodes that I currently have. I’m currently looking for a way to lock the mouse to the viewport so when I reach the bounds of the viewport, my mouse can continue moving but will never leave the viewport.