[4.27.2] How to get mouse position of the OS, before player controller exists?

I put a debug message call in the player controller’s Tick() function to track the mouse position. At game startup, the player’s mouse position is -1,-1 and stays that way for quite a while before then getting set to 0,1.
During startup, I want the mouse to be immediately positioned to where ever the mouse position was for the OS so as to prevent it from ugly jumping to the top left of the game screen.

My assumption is that the player controller sets the mouse to -1,-1 when the controller is spawned, so my thought is to capture the OS mouse position before the controller is spawned and then reference that OS mouse position once the player controller has been spawned.

Is this possible, and if so how?

I solved this by getting the GameInstance’s LocalPlayers list (which I could access directly from my project’s custom GameInstance).

I then simply saved the mouse position during GameInstance::OnStart() and then re-set the mouse to that saved position in the player controller’s tick (filtered with code so it is only set once when needed during startup).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.