How to display results at the end of a game?

I’ve been trying for nearly a month to do this. I don’t know if I’m just stupid or if this just as really complicated an ordeal as everything I’ve found. The problem is really simple: I’m not really good at UE4. I am making a game for a jam whose rules are that I can’t use an engine I’m familiar with. I have succeeded. I have made a game in UE4 and I am basically done with it. What do you do in the game? You collect coins and find the end of the maze. That’s all you do. All I want is a message at the end that tells you how many coins you collected and how many you’ve missed. That’s all I want. I can’t find out how to do it from anywhere and I’m beyond frustrated at this point. Can’t somebody please help?

what is the method in which you collect the coins? Is the coin a blueprint itself?
every time a coin is picked up are you adding 1 to a running total?

is THAT part working as it should first? You’ll need a variable storing how many coins have been collected and how many weren’t. Do you have that much working so far?

Yeah, I’ve got everything working…part of the reason I’m so frustrated. It shouldn’t be the hard to figure out. I feel like I know how to do it, and then I try to do it, and I can’t get anywhere. The coins have their own static mesh and are destroyed in the character blueprint. I’ve got a widget counting and displaying the coins I pick up. Let me grab some screens of the coin and character bps.

][3]

And that’s everything, I think.

You know, thinking about it, I’m not sure if any variables are tracking how many coins are available.

To display the totals at the end… what is your end condition? When they hit a new collision box it triggers end of game?

  1. Create a widget, call it EndDisplay
  2. In the widget, in the centre of the screen, Type the text you want to display “End of game!”
  3. Then make a second text called “coinsCollected”
  4. Then a third called “totalCoins”
  5. Arrange them however you want. You can add more text in there that says "you’ve collected: " of if you want
  6. bind a function to coinsCollected and totalCoins like you did in your other widget
  7. Do the same thing to get the coins collected and totalCoins int from your charBP
  8. Save it
  9. In your CharBP, create a custom event. Call it show EndDisplay.
  10. Use a “create widget node” choose end display drag the result to a new node called Add to View port and a Final node thats “Set input mode UI only”
  11. This is where I donno what your “win” condition is. But I’ll assume its when the player passes a trigger box or something So when that happens from wherever, just call the EndDisplay function and it will pop that widget up on the screen showing the totals and whatever text you have on there.

You can even add some buttons to restart the game or quite… etc.

Ok.

So I’m going to assume thats all working. The total coins is being added up properly and the widget is displaying the amount of coins collected as it collects them.

I’m assuming you placed the coins to be collected by hand. But it doesnt really matter. First to get the total coins:

  1. Open your character blue print
  2. Create a new function called TotalCoins
  3. In, start with a “get all actors of class” and choose the coinBP
  4. Drag the array out to a forEachLoop
  5. Create a new Int variable called total coins
  6. In the loop, get total coins + 1 then SET total coins
  7. In the envet graph, go to event begin play
  8. drag out a timer and choose set timer
  9. Put the name TotalCoins in the timer and set the time to 1
  10. Gives the map a second to load then it will count the amount of coin bps in the map and give you a total coins count in Total Coins int variable

To display the totals at the end… what is your end condition? When they hit a new collision box it triggers end of game?

  1. Create a widget, call it EndDisplay
  2. In the widget, in the centre of the screen, Type the text you want to display “End of game!”
  3. Then make a second text called “coinsCollected”
  4. Then a third called “totalCoins”
  5. Arrange them however you want. You can add more text in there that says “you’ve collected: < coinsCollected >” of < totalCoins > etc…if you want
  6. bind a function to coinsCollected and totalCoins like you did in your other widget
  7. Do the same thing to get the coins collected and totalCoins int from your charBP
  8. Save it
  9. In your CharBP, create a custom event. Call it show EndDisplay.
  10. Use a “create widget node” choose EndDisplay widget, drag the result to a new node called Add to View port and a Final node thats “Set input mode UI only”

Lastly, This is where I donno what your “win” condition is. But I’ll assume its when the player passes a trigger box or something So when that happens from wherever, just call the EndDisplay function and it will pop that widget up on the screen showing the totals and whatever text you have on there.

You can even add some buttons to restart the game or quit… etc.

Hey glad to hear!

The first part should have worked as well. Try doing it in the level blueprint instead of the character blue print. You can cast to your character once you have the total and set a character variable then if you still need total amount of coins. I tested that in the level blueprint so I know it works.

Worst case I suppose is that you can just manually count them and manually type the total!.

I converted my comment to an answer. If its all working, choose one and close the question.

Good luck with the game!

Thank you so much. So the first method didn’t work. forEachLoop would not connect and I was not allowed to set to +1. For the second method, steps one through ten went perfectly. My trigger box won’t call the EndDisplay. Sorry, it casts to EndDisplay, or I have to cast to a widget and then select EndDisplay. Or I have to cast to a Widget Component and select EndDisplay. Doesn’t matter, I’ve tried them all. I can’t get an event to work with them in any capacity. The error is “‘End Display’ does not inherit from…” Don’t ask what it doesn’t inherit from. It’s clearly an orphan and not entitled to an inheritance. Does not inherit from actor, actor component, abstract nav data, ai controller, player controller, game controller…yeah, I tried a LOT of things. It inherits from widget, but that apparently won’t trigger.

Never mind, I got it! And it works perfect. Start with EventActorBeginOverlap Don’t cast to your widget. Create Widget. Then Add to Viewport! Again, thank you so much! The second method works perfectly!