Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    Originally posted by sr3d View Post
    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.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Originally posted by eXi View Post
      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?

      Comment


        #4
        Originally posted by sr3d View Post
        I see, so ultimately there are three ways.

        Which would you say is the best or allows the most flexibility?
        :O 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.
        Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

        My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
        (Including 100+ Pages Multiplayer Network Compendium to get you started.)

        Comment


          #5
          Originally posted by eXi View Post
          :O 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?

          Comment


            #6
            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.

            Comment


              #7
              Originally posted by CriErr View Post
              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

              Comment


                #8
                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.

                Click image for larger version

Name:	d.jpg
Views:	1
Size:	182.7 KB
ID:	1094020

                how to move camera with edge panning scrolling

                Comment


                  #9
                  cool, thanks

                  Comment


                    #10
                    Originally posted by MeshMyster View Post
                    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.

                    [ATTACH=CONFIG]67700[/ATTACH]

                    how to move camera with edge panning scrolling
                    Most of the times my cursor doesn't fire correctly using this or similar setup ? Using Engine Version 4.20

                    Comment

                    Working...
                    X