Score BP?

AAAAAAARRRGGGGH! Why does this not work!?

I’ve set up the following BP it needs to output a count to screen of how many times the player enters a trigger volume:

Although I have Score widget its pretty much blank, I’m not sure how to set this up, and is it actually needed?

Is there anyway this can be set to output at the end of play?

Can someone please help.

Nothing after Print String will do anything because there’s no execution wire. You should be able to connect white from the first Set node to the Print String.

Secondly I don’t think the Overlap will fire without you checking for another actor. In fact I just had a quick look in the Documentation and this should help.

I’m no expert on widgets. But if you just want the score printed out to the screen then you won’t need the Score Widget. or anything after it. Also note that the second Set node will always set the score to 0, which I doubt you want to do?

Thanks for that Kev, it’s very much appreciated if I connect the first set node to the print string will that output to screen correctly mate?

I definitely don’t want the result to always be zero, I’ve got a number of volume triggers placed around my map as gates I just want something that pops up on the screen (preferably when the game ends) that shows how many times the player has used a gate.



Now you have the Score Integer Variable in your Score UMG.

If you want to display it, use a Text widget: Widget Type Reference | Unreal Engine Documentation

and Bind the Text value to a Function where Return Node = Score Integer Variable: Property Binding | Unreal Engine Documentation

Thank you so much for that Diat I really appreciate it, additionally I’ve seen you’ve got time showing in your fps template, can I ask how you managed to create that as it’s something else I’m trying to create.

Nice one Diat Funa.

A question from me now: My assumption is that we’d want to include a cast in the Your Overlapped Actor graph. Is that not necessary? Else won’t we be counting all overlaps, not just those between player and trigger volume? Thanks in advance if anyone can explain that one. :slight_smile:

Here it is:
Started by Begin Play connected to the Gate [Enter]…

Hi Kev!
You don’t need Cast nodes in Your Overlapped Actor because you get the variable you want to display (“Score” Int variable) from your widget blueprint with Get All Actors of Class —> GET —> Variable.

About the overlap question, we have some Collision Presets: Collision Response Reference | Unreal Engine Documentation

Overlap Only Pawn is a good preset for the actor we want overlap, because only pawn actors can overlap it…all other actors will be ignored or blocked. If you have many Pawn Actors but you want overlap the actor only with your playable character, you can create a Custom Collision Object/Preset (with the same Collision Pawn settings) and assign it to the non-playable actors: Add a Custom Object Type to Your Project | Unreal Engine Documentation

Thanks Diat! Very much appreciated!


Just so you know, you should avoid “GetAllActorsOfClass” if possible. It’s not a good coding habit!

The way this can be solved here, is the following:

In the UMG Score thing, create a variable of type: “YourOverlappedActor REFERENCE”. This will be empty by default, as you need to fill it with an
instance of the class. You currently get that instance with the AllActors stuff.

Click on the Variable again and go to its options. Select “Editable” and “ExposeOnSpawn”. Save and compile.

Head back to the “YourOverlappedActor” Blueprint. Check out the “Create Widget” node. It should now feature a pin of your variable. (If the UMG Score Widget is selected to be spawned!)
Drag it out into an empty spot and search for “Self”, which is a reference to the Actor your are working in.

Then you can use that variable in the Widget (:

EDIT: Also, why do you create the Widget EVERY TIME the thing gets an overlap event?

Create the Widget once on BeginPlay of your Controller or what ever. Save it to a variable and just leave it rest there.
If you want to hide/show it, you can always just get your controller, cast it to your custom class and access the Widget variable.

Hey @eXi, many thanks for your contribution…that was just an example.

I usually create the widget with Begin Play, SET a variable (variable type is = widget) and when I want to add the widget to Viewport I use this variable.
Is this the best method in terms of performance?

Yeah, it’s fine. Just remember that you answer questions here. Even if YOU do it otherwise normally, you teach people to do it wrong right here.
If you provide examples, make sure they are logical correct and explain why you did what you did.

I know that OP had the create widget in the overlap already. Would’ve been better to show him a general correct way (:

Keep up the good work though!

OK eXi, many thanks again :o

Ah yes we can use collision presets, I should have thought of that. So much to learn but also so much to try to remember! Thanks. :slight_smile:

Thank you guys for all your help much appreciated, I’ll probably still need help putting it together and getting it to work though!
@eXi can you please show me what you mean in terms of how the bp should look as I’m having difficulty following what you mean exactly.

Ok guys slight problem, I have followed the examples above but my count always starts from 2 instead of 1.

I’ve ultimately gone with the most basic setup without using widgets and I’m trialling with only two trigger volumes (gates) that each time the player goes through each should increment the count by 1.

I also only want to print the contents of the score variable yo screen when the game ends?

Please help guys!

Two questions:

  • What exactly gives you +1 score? A coin or something else that disappears after collecting? A gate, through which you can run multiple times?
  • What is the “Game ends” criterium?

Each time the player character goes through a trigger volume.

I’ve currently got it set up that when the player goes through a final trigger volume it executes the end game quit function

Alright, give me a bit time and I give you an example setup with comments

Thanks eXi much appreciated!

Alright, first thing to do, if you haven’t yet:

  • Create a new Blueprint Class and use “PlayerState” as the parent!
  • Open your new PlayerState Blueprint (I called it “BP_PlayerState”) and create a “CurrentScore” Integer Variable
  • Also create the following Custom Event (see image)
    – We use it to increment the Score by an incoming amount, so you can have different values for your gates (if needed)

Now we need the Widget, in which we display the score:

  • Create a new Widget (mine is called “W_ScoreScreen” and open it up
  • Add a “Text” where ever you want it, you can see my settings in the image below

  • Now, select the Text and look at the right side into its Details
  • At the top, give your Text a proper name. I called it “ScoreText”
  • Also mark the boolean “Is Variable” with “true”

  • Open the Widget Graph (Top right)
  • You should see a grayed out “Event Construct”. If not, search for it in the right click menu
  • Now do the following (see image)
    – This will take care of grabbing the score from our PlayerState when we create and add the Widget to the screen

Now next is the GameState. This handles the general state of the game and will take care of ending our game:

  • Create a new Blueprint Class and use “GameState” as the parent! (4.14 still GameState, not GameStateBase!)
  • Create a Reference Variable for your Score Widget
  • Create the following Custom Event (see image)
    – We use it to end the Game and display the Widget
    – We also make sure that we don’t create and add multiple widgets

Now we only need to actually have the two triggers.
Lets create the Score Adding one first.

  • Create a new Blueprint Class of Actor (parent) and called it “BP_ScoreTrigger”
  • Now add a Box Collision to it and call this one “Trigger”
    – This overlaps “All” and is a “WorldDynamic” by default. Guess we can keep that
  • Now click on it an create the “OnComponentBeginOverlap” event (see image)

  • After clicking the green button, we automatically travel to the Event Graph and the new node
  • Now add the following code to it:

This make sure the Actor is our Player (my class here is “BP_PlayerCharacter”, you need to use yours) and then gets the PlayerState
from it (which can be done from Character and PlayerController, so we get it from the Character directly) and cast it to our custom class.
Now call the add function and we are done.

Last thing is the end trigger, so go though the process of

  • Creating a new Actor Blueprint Class (mine is called “BP_EndTrigger”)

  • Adding a Box Collision

  • Adding it’s “OnComponentBeinOverlap” event again (same as before)

  • Now add this code:

That should be it. I haven’t tested it yet, but if you run into problems, just post them (: