Announcement

Collapse
No announcement yet.

[UMG] Best way to dynamically create widgets for in-world objects on the fly?

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

    [UMG] Best way to dynamically create widgets for in-world objects on the fly?

    Hey guys,

    Imagine you have a list of targets/enemies, with their positions, health, etc. I'm trying to make an overlay that can display that data over the enemy in the world, as well as highlighting them.

    (Imagine a more modern version of this).
    Click image for larger version

Name:	before2m.jpg
Views:	1
Size:	212.3 KB
ID:	1138504

    I could create a 'target' widget, with inputs for any relevant data about the target in question, and then project/deproject as needed (how is this supported re. the viewport?). These would need to be constructed for each target and destroyed as necessary. They would also need to be updated and moved.

    I understand most of this conceptually, but I have to wonder if this is a favourable approach? Has anyone else created similar UI elements and has a better method?

    Thanks.

    #2
    You're talking about a 3D widget, right? Like, UI info on a 3D object in the world? According to the 4.4 Part 1 broadcast, 3D widgets through UMG aren't currently supported, but will be in future releases.

    However, there may be a way to do something through customized Slate code. I remember seeing a tutorial video about making a 3D widget that manipulated objects in the editor, and Slate can be used to create UI in editor and in games.

    Others, since I'm still developing my understanding of UE (its UI systems in particular), am I incorrect? Any input appreciated

    Comment


      #3
      Someone correct me if I'm wrong, but I'm pretty sure the next engine update has some major UMG enhancements, maybe something like that is possible with the 4.5 release?

      Comment


        #4
        Originally posted by sethj11 View Post
        You're talking about a 3D widget, right? Like, UI info on a 3D object in the world? According to the 4.4 Part 1 broadcast, 3D widgets through UMG aren't currently supported, but will be in future releases.

        However, there may be a way to do something through customized Slate code. I remember seeing a tutorial video about making a 3D widget that manipulated objects in the editor, and Slate can be used to create UI in editor and in games.

        Others, since I'm still developing my understanding of UE (its UI systems in particular), am I incorrect? Any input appreciated
        A system like that is meant to be a 2D representation of the 3D world, not a 3D UI. You can absolutely do that in Unreal right now.

        Iterate through all the actors you want a targeting reticle over. Get their world location. Use the World Location to Screen Location blueprint function to get a screen coordinate. Use that screen coordinate as the position of your reticle. (As a note your reticle widget's pivot should be from the center, not the top left or anything like that.) The coordinate system MIGHT be different between what you get there and what UMG uses, if so you'll have to convert between them, but that's not too hard.

        You'll have to do some math to figure out what objects are actually on screen in order to have arrows pointing offscreen in the right direction when appropriate, but if you need help then ask then. Don't worry about it yet, just get the basics working first.

        Comment


          #5
          World To Screen Projection

          Veovis is absolutely correct!

          And please note I am the one who submitted the C++ code for the World to Screen BP node to Epic so that everyone can now use it in BP as of 4.4 !

          Here's my now completed pull request:
          https://github.com/EpicGames/UnrealEngine/pull/301


          I am not saying this to be boastful, but rather to show you that I really do care about everyone in BP having as much power as possible.

          That's why I take the time to submit my c++ pull requests to Epic, for your benefit!

          ~~~

          Pic for You

          Here's a pic of the general setup!

          Notice with this setup you can now project world to screen from anywhere, you are no longer bound to the HUD draw loop and the hud class!

          I am doing this in the Level BP !

          Click image for larger version

Name:	WorldtoScreen.jpg
Views:	1
Size:	115.0 KB
ID:	1057133




          Rama
          Last edited by Rama; 09-26-2014, 09:17 AM.
          UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

          ♥ Rama

          Comment


            #6
            Hey gus, I just hop into this thread. I have no problems with the maths, I have it working using Canvas->Project() and simple Canvas-text, but I have no clue how to get it working with UMG.
            Can somebody explain the UMG side of things?

            Comment

            Working...
            X