Getting variable to display on screen

I’ve got a variable that’s based and updated in my levelbp called “gate number” that holds an integer value that increments through trigger volumes, but I need to write this to screen.

I’ve created a widget with some text that says “Gates:” and another text field next to it let’s call it “total gate number” that I want to hold the value of my variable in the level bp, how do I do this?

I’d appreciate some help guys.

You need to bind the gate# field to some function. In properties next to the textfield, click bind then create a new binding. It adds this as a function next to the event graph. Add reference to levelprint and relevant nodes to access variable.

Thanks for that can you please show me an example as I’m pretty new to this

If you want to simply replace the Print String functions within blueprints you can, but be sure you fill out the node completely. Below is an example comparison of the two.


Here I am switching back and forth between the Print String and Debug Draw Text function.


Now whenever I press the ‘P’ key it will Print or Draw the value of the variable ‘Max Roughness’. A few things to keep in mind is that you need to enter a duration as it is 0.0 by default, and you need to give it a location to draw. In my case I just referenced the location of the player since I know it is always going to be in view and in the middle of the screen.


Thanks for that Andy, my main reason for not using the print string function is because I want larger and potentially nicer looking text to be placed in the top right of the screen that are easily readable, it doesn’t have to be overly fancy even the standard robot type text font that’s used in text widgets would do, I just need a simple (like me) way to get it done.

It also needs to be displayed throughout the game or at least at the end.

I’d appreciate your advice mate.


Is this not for gameplay display?

Either way, you need to make a widget, set a function, get a reference to where the variable is and add it to the viewport of your controller. Below is one of my setups that gets variables from the game instance and game mode. Add to viewport is after Event BeginPlay in the gamemode. I’m not sure how easy it is to use the levelprint for getting variables, I’d use GameMode or GameState to store map variables as these are easy to cast to and don’t require replicating levelprint to make new maps.


Hi LM,

It is for game display, but I’m trying to minimise the use of additional blueprints without extending standard classes like game mode, it seems overly complicated and I keep having bad luck with them.

I’ve currently got the value I need correctly writing out to screen using the print string function, but it looks pretty cheap and nasty because of the size of the text.

Can’t I just replace the print string function with a draw text function from the level blue print?

Well if you are set on using print/draw text but want to beautify it you can make a font in the content dropdown menu User Interface>Font, add a font from your system or custom TTF/OTF file. Default font dir on windows7 is /Windows/fonts, but for some reason this does not show in the editor folder selection for me. So copy into your own folder or look online for fonts. Make custom font in UE4, select size ect, go to Edit>Project Settings>Engine>General Settings and you can add your font into the selections. PrintString should now show your custom font.

Ah nice one, Thanks!