Edge Scrolling using UMG or basic HUD Hitboxes?

Hi, I’m working on a RTS Camera. Currently I’m moving around using the WASD keys, while I’m doing the zoom/rotation using the mouse. I’m trying to add edge scrolling so that I can move the screen around with mouse when the cursor is at the edge of the screen. I currently use a HUD Blueprint to draw command buttons on my screen, but I intend to move to UMG soon. I would like to know which of the following options to add edge scrolling would be the best practice:

  1. I add a button or some other widget at the edge of screen (as part of my command UI UMG), that are invisible to the player, but are visible to hit results. I then use their location to calculate the edge scrolling direction.
  2. I used HUD Blueprints to draw Hitboxes and then calculate the edge scrolling direction.

I will be adding a command UI to the viewport anyways. So I would like to know which would be a better option.

i don’t see why you need hit boxes or mouse over logic for that functionality. why not just subtract the mouse coordinates from the center of the screen, and if its over a certain distance, scroll based on that distance, multiplied by a speed constant.

I have followed this tutorial before, and while it’s not a simple solution, it works quite well and allows you to customize a lot of the settings once it’s setup:

Just make sure you triple-check everything you did on each step because it’s very easy to mess up one of the connections (which I did in several places when I did it).

Thanks a lot, that’s a good idea. But in the long run, I would like to know which would be efficient. In this scenario, every frame I will be having 2 to 4 branch conditions ticking to see which direction I need to scroll to.

Hitboxes are out of the question for me now. However, using UMG, I can add 8 invisible borders to change the necessary values without any branch conditions except the internal logic behind the mouse move events. I’m going to need a UMG screen anyways for the in-game menu for issuing movement and fire commands. So I was wondering which would be a better way to go.

Thanks, I had started with that tutorial, but I was able to implement a simpler solution using UMG. Now that Omnicypher has mentioned another solution, I’m gonna test out that code as well, and see which yields better frame rates.

UMG and Canvas hitboxes are both very efficient options, so it really doesn’t matter which one you use, but i think for an RTS scrolling camera, it would not feel very responsive if you could only move in 8 directions at a set speed. using the “distance and direction of the vector of the difference between cursor position and screen center”, would give you fluid results with fine control.

here is a flash project i made a long time ago that uses a camera based on the mouse cursors position. notice how you can easily control the speed and direction:
https://dl.dropboxusercontent.com/u/14534997/sSpadea_Project_C.swf

That was a good example man, and scary. :stuck_out_tongue: I’ve actually felt this issue when playing certain edge scrolling games a while back. But then I thought it was because I hadn’t played strategy games in a long time. You’re using something like interp there?

I will try this out. But the issue for me is that I’m having real time grid generation similar to what’s done in XCOM. So there’s a chance that unlike an RTS game like AoE, moving a camera around too much might interfere with the gameplay.