What is proper way to add edge scrolling? Get viewport size or UMG UI's on the edge of screen or?

Just curious what the best way is to add edge scrolling to a rts style game, what would the UE4 pros do?

Well, i don’t know if there is another way, but i guess i would get the Mouse Position and just use comparisons to check if i’m at the left, right, top or bottom
of the screen. Like, If(Mouse.X > 0 && Mouse.X < 20) i will move left.

I see, so ultimately there are three ways.

Which would you say is the best or allows the most flexibility?

:open_mouth: I don’t know about the other two ways. I only told you one way and that’s the way i would do it i guess.

EDIT: You could also add a widget with 4 invisible elements, one on each side of the screen, and check if the mouse hovers them.

Does this require that I only make one UMG.UserWidget and have like four borders in it or something?

i think having four 2 pixel borders would be easiest way.

also there are some camera examples in community content, with example of rts camera.

I looked at the strategy camera example, but it’s in C++.

So far I’ve figured out how to make a UMG.UserWidget, but I can only get one border in it. If I use a canvasPanel then I get a problem with sizing when in 16:10 or 16:9.

The only way I’ve figured it out so far is to make eight separate:

  • UMG.UserWidgetLeft
  • UMG.UserWidgetTopLeft
  • UMG.UserWidgetTop
  • UMG.UserWidgetTopRight
  • UMG.UserWidgetRight
  • UMG.UserWidgetBottomRight
  • UMG.UserWidgetBottom
  • UMG.UserWidgetBottomLeft

Then spawn these eight widgets from my camera component object. It works, but I wonder if I really needed to make eight different UMG widgets. It would’ve been nice to just have one blueprint with the eight border widgets inside it with the resizing automatically handled at 16:10, 16:9

move camera with edge panning scrolling

I ditched the UMG UI method and just use mouse cursor position and get viewport.

Here is the code if someone wants it. It works great, especially if you use a floatingpawnmovement component for the acceleration, deceleration, max speed.


how to move camera with edge panning scrolling

cool, thanks

Most of the times my cursor doesn’t fire correctly using this or similar setup ? Using Engine Version 4.20