What way can I get this mouse based movement system to work with all screen sizes?

I’m working on a side scroller in UE4.18 and the way I’ve set up controls is so when the mouse cursor is on the left or right side of the screen, the character moves to that direction. When I play it in fullscreen on a 1080p monitor, the controls work perfectly (since 1080p is how I have the blueprint set up with right now). Of course since my blueprint is set up with 1080p in mind, the positions don’t work so well when playing in a smaller window or on a lower res monitor.

Is there a way I can change this to have it work on all resolutions, rather than just 1080p?

Hi EAPyoutube,

You can use the method form any player controller object GetViewportSize, it will give you the current size of your viewport (in fullscreen it will give you 1920x1080, if is in editor it will give you the current viewport size). With that size you can convert current mouse position into a normalized vector (from 0 to 1), then you can ask if X value is less than 0.5f to go to the left or > 0.5f to go to the right (or another value if you want to give a dead zone).

Hi! Thank you for responding with a solution.

I have a problem though. I’m not sure how exactly to set up this blueprint you’ve shown me with the character movement. Would it be possible of you to show me a full character blueprint, with this method you’ve shown me implemented?

Thanks!

I got it to work! I added some dead zone by setting the values to 0.45 and 0.55. You did make a mistake here, which is that you set the X values to 1 and -1 when it’s supposed to be Y, but I quickly discovered that when I looked into it.

Other than that, thank you!