Locking mouse to viewport

Hello there!

I am trying to find a way to lock my mouse inside the boundaries of the window/viewport for my RTS camera. I have tried doing


The issue is that this causes the editor to crash. I have tried this in the constructor for the pawn, HUD, and player controller, but all cause the editor to crash.

Connor Brewster

Any progress to this?

Don’t do calls in constructor because it’s used exclusively variable defaults and there initiation, it’s called (may even few times) in very premature state, in that point viewport does not exist, so you calling to null pointer and cause the crash. Call it on BeginPlay() instead.