[BUG] PlayerController GetViewportSize returns incorrect size in editor

Version: 4.7.6

When you’re using the GetViewportSize in editor, it should return the size of that editor panel, but it seems to return the values we set in the editor prefs for the standalone windows.

Hi nafonso -

Can you give me some details of how you are setting up this test? I’ve tried a few ways in 4.7.6 and it is always returning the correct viewport size. Here are my tests:

In Player Controller Event Graph:

  1. Add a Key Press Event for “H”

  2. Add a GetViewportSize node (non-HUD)

  3. Pull off GetViewportSize node and Break Vector2D

  4. Add (2) Print String nodes

  5. Connect the X to one of the Print String nodes and the Y to the other.

  6. Connect “H” key press to X Print String

  7. Connect X Print String to Y Print String

  8. Compile and Save

  9. Add a Key Press Event for “J”

  10. Add a GetViewportSize node (HUD)

  11. Add (2) Print String nodes

  12. Connect the X to one of the Print String nodes and the Y to the other.

  13. Connect “J” key press to X Print String

  14. Connect X Print String to Y Print String

  15. Compile and Save

In Level Blueprint:

  1. Add a Key Press Event for “K”
  2. Add a GetViewportSize node (There should be only one this time)
  3. Pull off GetViewportSize node and Break Vector2D
  4. Add (2) Print String nodes
  5. Connect the X to one of the Print String nodes and the Y to the other.
  6. Connect “K” key press to X Print String
  7. Connect X Print String to Y Print String
  8. Compile and Save

Let me know what you are doing different -

Eric Ketchum

Well this is odd… Since I reopened UE it is working.

In the HUD BP, I was calling GetViewportSize, and it was always returning 640x320. Now it returns 1172x730 (basically the view size).

However, something that was working before, isn’t working now. Previously, when I launched the game with 3 players, I’d have half top of the screen with player 1, and then bottom divided in 2 with player 2 and player 3.

Now, it shows a black screen, and only the UI is visible. The game is running, because if I move the character around it does die, so something odd is happening with 3 players.

If I choose 1, 2, or 4 players, it works normally.

Can’t reproduce it again, feel free to close it, sorry for the trouble. If it comes up again, I’ll reopen it. In the mean time I’ll try to reproduce the other issue on a clean project.