Is there anyway of being able to display text permanently using the print string function node, as I’d like to display some stats when the game ends, so the player can read them at their own pace, but its only staying up for the few seconds I can set within the node itself?
Why not display text in a umg widget then remove it when ready?
I’m trying to avoid using widgets
UMG is easiest way to do it, especially so it will look nice.
Otherwise, just keep drawing the print string ontop of itself on a timer loop. But, that’s hacky. It is really meant for Debug data I believe.
Sorry but, this is the wrong idea.
PrintStrings are not mean to display PlayerData. In fact, you can’t even see them,
if you package your game later for shipping.
There are 3 things you can use to display things on the viewport/screen.
- Slate: That is the written UI language that sits behind Widgets. It’s basically like C++ for Blueprints.
- UMG (Widgets): The more userfriendly and Blueprint supportive way of creating UI. It’s a child form of Slate, as said before.
- HUD Class: HUD Class gets spawned with the Player and can be accessed via the PlayerController. It’s old, and most people don’t use it anymore
as it’s way too much work to actually create an UI with it.
If you want to create UI for your game and you are not able to use Slate (or you simply don’t want to use it), you will have to use UMG.
Of course you can use the HUD Class, but that’s insane
Why are you avoiding the Widgets anyway? If you don’t understand how they work, you should rather spend some more time on learning, instead
of avoiding them.
Hi exi thanks for that it’s most informative, I’m not having much luck with widgets and I need to get a prototype out by Thursday.
I’ve got the gate count working now using print string functionality, how can I get this to work from the level BP with umg easily, every time I start adding extra bps it just doesn’t work and I’m critically short on time.
Well, it’s normally really simple.
- Create a new Widget Blueprint
- Add a TextWidget to it with the Designer
- Go to the Event Graph of it and add a new TEXT Variable, for example called “MyText”
- Go back to the Designer and click on the TextWidget
- Go to the details panel on the right and search for the part where the actual text gets typed into
- Click on “BIND” and select the “MyText” Variable
– Now the TextWidget will show what ever the MyText variable has
Now, where ever you need to, you call “Create Widget”, select your new Widget class in there,
set it to a Variable, so you have access to it later and then you can instantly call “Set MyText”
on it, where you set the Text variable with what ever you want to display. After that, you simply call
“Add to Viewport” onto the Widget you created.
I mean, this is really basic And there are 100% video tutorials on Youtube that show you exactly how to do this.
I’m going to try and knock this out tomorrow, I’ve only got 2 variables that need output ones time in seconds and the other an integer count.
I’ve followed multiple tutorials but I can’t find one that works exactly as i need it and from then onwards it’s difficult to follow and realise.
If your list is complete (regardless of being basic) I’ll definitely give it a go, thanks again eXi!
Ok I’ve done this with two variables in the widget BP: ScoreText and TimeText
But how do I get the data from my “score” variable in my LevelBP to update the “ScoreText” in the WidgetBP?
Where is your Score located?
Why are you even using the LevelBlueprint?
my score variable that counts the number of gates is in the level BP, I’m trying to pass this to the new “stats” widget I’ve created.
Well, you created the Stats Widget with the “Create Widget” node, right?
That has a return value at the right end, which is a reference to the Widget.
Save this to a variable (drag it out and release on an empty spot, select “Promote to Variable”).
Then, use that variable and call “Set ‘VariableName’” on it.
That’s how you set the Variable. If the Score variable is in your LevelBlueprint too, then
you can just connect that.
Ah ok, so basically when I call the widget in the level BP, I also need to assign the variable in the level BP?
You basically do this:
Of course the CreateWidget node needs to be connected on the left, but I don’t have time to set that up.
I’m a bit confused I’m running 4.12.5, I can’t seem to “set variable name”?
Even in the blue “set” function I can’t set “score widget” I think it’s just chosen a default value?
Your “NewVar2” is the ScoreWidget Variable. I just renamed it.
Why are you setting “Score” with “Score” that makes no sense.
I told you to create a Text Variable IN the Widget. So if you’ve done this,
drag out the “NewVar2” pin, and call “Set …”, no idea how your Variable is called
in the Widget.
The variables in the widget are called “ScoreText” and “TimeText”
If I pull out the new var 2, I get this, how do I set the asset I cant connect the second SET function to the ToText function either?
This is all that’s in the stats widget after binding the score text and setting it as a variable:
The Variable you have there is a “Text Widget” variable. You need an actual TEXT Variable additionally.
My Widget Designer with the TextWidget in it.
On the right you see that I bound a function to it.
Now, inside of that function (you have it too “GetScoreTextText0”), i bind a TEXT VARIABLE, which I created additionally
(you see it on the left), to this.
And this TEXT VARIABLE is the one you want to set in the LevelBlueprint.
This is what mine looks like now:
I know you want to murder me now, but please help me get this to work, I can die happy then!
I’m still struggling.
Is it exactly the same process to pass my time variable into the Widget too?
As I’m sending two variables to this widget, I’ve got it reading and outputting score but I also need it to to read and out put time, how do I do this?
I was feeding this in as a “GetTotalSeconds” function