Announcement

Collapse
No announcement yet.

Widget BP for varying camera angles

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

    Widget BP for varying camera angles



    I’m using a “MiniMap-Widget” to show the level from different angles. I want to be able to switch from one Camera to another at runtime. I was able to achieve the desired result by adding a widget to the viewport and on press Tab remove the existing widget and placing a new one.

    Somehow this feels clumsy to me, it seems like instead of creating several widgets that all use their own material which use their own SceneCapture2D, I should have been able to:
    1. Switch the material within the widget BP, my problem here was that the widget BP does not allow any keyboard events.
    2. Switch the textures on the material. This seems to only work on actors placed in the level but not on widget BPs.


    The solution that I have come up with works and does what I need it to do, however I feel like it’s not the best solution possible. Currently I am using 3 widgets, 1 material and 3 material instances, and 3 Canvas Render Targets. It seems it should be possible to use only one widget, 1 material + instance, and 3 render targets. Which brings up the question of resources being used.

    I’d greatly appreciate if anybody would take the time to look at this and maybe shed some light on it.
    Tobi Thuerk
    3D Visualization Artist
    Elkus Manfredi Architects, Boston

    #2
    - In your HUD class create Main Widget in Begin Play (and set reference via variable).
    - Create widget for each camera, and put them in Main Widget (as user custom). Or one custom widget for all cameras with switch.
    - In your player controller, cast to your HUD, get reference from your Main Widget and control via keyboard (or any input) visibility for each custom widget.

    Comment


      #3
      Thanks so much for the response Mr. Wood.
      I'm not really sure though how your approach is an improvement. I was hoping to simplify things, instead I have now added more complexity to the system. In addition to the three widgets from before I have now one more widget, a HUD, and a PlayerController. Granted in a project that goes beyond just a sample I would most likely have a PlayerConroller and GameMode anyway. I was hoping to be able to switch the textures or materials that the widget uses, any ideas on that?
      Tobi Thuerk
      3D Visualization Artist
      Elkus Manfredi Architects, Boston

      Comment


        #4
        I know that sometimes it looks more complex, but later it's easier to control everything. For instance, if you create widget from your Character BP, and than remove that character or possess another character you need to transfer all references to another character so he can use the same widget. And it can be painfull and more complex, specially for multiplayer games.

        "Switch the material within the widget BP, my problem here was that the widget BP does not allow any keyboard events."

        This is basically why I wrote this. You can access it via Player Controller and hide/show any widget you want or whatever you want.
        So, in HUD create your Main Widget and set reference variable (so you can access it via Player Controller).
        Inside that widget Add other widgets as "Child" (user widgets). So you can always access to specific widget. To do this find your other widgets from Drop down (in Pallete) and drag it into "Hierarchy".

        How to access widgets via keyboard events?
        Via your player controller. Cast to your HUD class, call reference of your Main Widget that you previously set. Now you have all widgets. To access specific "other widget" simply: Cast to your HUD, call Main Widget -> Call your "other widget 1" or "other widget2", set visibility to false/true. In this way you always have control over your widgets.

        Comment


          #5
          And about material:
          Just create one and set the "Material-Domain" to "User Interface", drag in your render target and connect the color from that to the final color.
          You have to plug in the alpha (last pin on the texture sample node) to the opacity with a "OneMinus" node between them. You can render this material in the widget.

          Comment


            #6
            Thanks so much for the longer explanation, certainly makes sense that the easy way of doing things sometimes doesn't scale up.
            I'll take a look at all these suggestions and report back.
            Tobi Thuerk
            3D Visualization Artist
            Elkus Manfredi Architects, Boston

            Comment

            Working...
            X