Announcement

Collapse
No announcement yet.

Convert World Location to Screen Location bug ?

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

    Convert World Location to Screen Location bug ?

    Hello everyone,

    In my third person shooter, I 'd like to display a dynamic crossair. My problem is that it is not displayed at the right location, there seems to be some constant offset between where the real location and where it is actually displayed. The node Convert World Location to Screen Location seems to be buggy... Is it a known issue?

    I work with UE4.6.

    Thanks !

    #2
    Since you're talking about a constant offset, could it be that the crosshair's anchor point is placed at the screen location, instead of the center? Perhaps setting the anchor point to the image's center makes a difference:
    Click image for larger version

Name:	alignment.png
Views:	1
Size:	30.6 KB
ID:	1067504

    If thats not the case, could you provide a screenshot of how it looks?
    Journeyman's Minimap - Available on Marketplace - Forum topic - Video

    Comment


      #3
      Here's a screenshot.

      Click image for larger version

Name:	screen.png
Views:	1
Size:	598.1 KB
ID:	1067509

      In 4.7, the same nodes work and my dynamic crossair looks good. Unfortunately, I can't upgrade to 4.7 ...

      Comment


        #4
        Ah, it doesn't seem to be the crosshair image's anchor then. I'm afraid I can't think of anything else right now.
        Journeyman's Minimap - Available on Marketplace - Forum topic - Video

        Comment


          #5
          Are you running the game in Fullscreen? The Projection doesn't seem to factor in the current windows size right now. If you go Fullscreen, you might see it move location.

          Comment


            #6
            Hey, I have the same problem. I have some UMG widgets that will go left and up. I think this started once I launched my game on Android. There's a thread about this on the answer hub but I wasn't able to find the file they were talking about:

            https://answers.unrealengine.com/que...n-locatio.html

            Comment


              #7
              I had a similar problem just now and found my solution somewhere else on this forum. Posting here because I remembered this thread.

              Stuckbug mentioned here:
              Based on the screenshot, it looks like maybe your editor kicked in scalability settings? I've noticed that world to screen functions get messed up if the editor does a resolution scale, which can happen automatically during times of poor performance.
              Setting the resolution scale to 100% solved the issue for me:
              Click image for larger version

Name:	reso_scale.png
Views:	1
Size:	96.4 KB
ID:	1071374

              Maybe this works for you guys as well.
              Journeyman's Minimap - Available on Marketplace - Forum topic - Video

              Comment


                #8
                ConvertWorldLocationToScreenLocation predates UMG, it's only designed to give you correct screen locations if you're using it for screen related things that map directly to the game's resolution, like AHUD/Canvas.

                UMG/Slate do not exist in the same 2D unit space as the rest of the game. The game's resolution scale is one source of that difference, another is DPI scale. If a DPI scale has been applied, you still need to transform that "Screen Location" which is in Resolution Scaled, and non-DPI space, into the space of widgets if you plan to use it with UMG. There's a couple of utility functions that might be in 4.6, UWidgetLayoutLibrary::GetViewportScale, which if you applied the inverse of, after applying the inverse resolution quality, you'd arrive at the proper position for UMG for fullscreen UI.

                If you'd like to grab from GitHub, I've added a utility for 4.8 to make this task easier, it's UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition.

                Comment


                  #9
                  If you'd like to grab from GitHub, I've added a utility for 4.8 to make this task easier, it's UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition.
                  That sounds great Nick! Would you say this is the intended way to position widgets over actors?
                  Journeyman's Minimap - Available on Marketplace - Forum topic - Video

                  Comment


                    #10
                    I know the above explanation is better, but if anyone reading this don't feel like grabbing 4.8 from GitHub, you can just multiply the output "Screen Location" by viewportscale to the power of negative 1, like so:

                    Click image for larger version

Name:	solution.jpg
Views:	1
Size:	30.2 KB
ID:	1072400

                    I am not sure whether this has other consequences further down the line, but so far it seems to work for me.

                    Comment


                      #11
                      That worked perfectly for me, mrzapp!!!! Thanks!
                      Check out my ★★★★★ UE4 plugin if you want to go fast!
                      • Feedback Event Factory: Perfect for managing sounds, particle systems, force feedback, camera shakes, time dilation, animations & more...all within a single Blueprint!

                      Comment


                        #12
                        Originally posted by mrzapp View Post
                        I know the above explanation is better, but if anyone reading this don't feel like grabbing 4.8 from GitHub, you can just multiply the output "Screen Location" by viewportscale to the power of negative 1, like so:

                        [ATTACH=CONFIG]34771[/ATTACH]

                        I am not sure whether this has other consequences further down the line, but so far it seems to work for me.
                        This worked for me perfectly. Thanks for your solution.

                        Cheers.

                        Comment


                          #13
                          Thanks mrzapp! Works great and helped me out a lot!

                          Comment


                            #14
                            My god!!!! This helped me alot on my multiplayer splitscreen game!!!

                            Comment

                            Working...
                            X