Game Mode Winning Conditions

I’m trying to make a game mode where you need to collect all of the coins in the level to win and the time you took to collect them is recorded.

I’ve got a blueprint for the coins set up so you can collect them and the timer counting up at level start. The problem is that I don’t know how to go about tracking how many coins are in the level and capturing the time when the last coin is touched to display on the scoreboard.

Anyone able to help out with this?

You can use “Get all Actors of Class” and choose the Coin Class. This will return an array of all coins. You could check the Length of the Array every tick (or maybe everytime a coin was picked up) and if the Length is 0, the player collected all coins. All of this works providing that you delete the Coin Actor if it gets picked up.

Or just make coin send info to game mode class when it’s collected and gamemode just substracts the number, i think that would be liter

Yeah, for sure, he could either have an Int Variable set by hand (like 10 coints) and substract everytime he finds a coin, or let the Variable be set by the “Get all Actors of Class” on Begin Play, so he could have different amounts of Coins. (Still letting the Coin Pick Up function reduce the Variable).

Then he would need to check the Int Variable and if this get’s 0, the game would be finished.

I guess both ways work. Somehow :smiley:

Thanks guys! Actually I’m going to try to get it to work using eXi’s suggestion as I want to be able to have a different number of coins with every level as the game’s difficulty increases. I’ll post back here once I’ve made some progress.

Wow that was a lot easier than I thought it would be! Thanks for pointing me in the right direction guys!
Here’s what I did:

Now I just need to figure out how I can take what the current time is from my timer and print that to the screen along with the “You Win” text. I’m going to look at the Time Attack tutorial Epic posted to see if I can figure this out.

When I do I’ll create a tutorial on how to do the entire thing.

Hi, I’ve tried to follow this solution but I just don’t seem to be able to hook it into my blueprint correctly. I’ve got a function to count items, destroy them on overlap and display the number in HUD. The game has a timer which ends the game on 00:00 and is again displayed in HUD. What I can’t figure out is where to connect the logic that says when all actors of the acorn class have been destroyed end game. I’ve tried plugging the BP abov into the game mode but the event tick is already driving the timer the event begin play is driving the HUD. I tried plugging it into the Acorn BP before and after the actor is destroyed but it still doesn’t work. Any help is much appreciated. Andy

Ok so I’m guessing that your dash dog bp is your player character?
Always add a print string to the end of the Cast Failed to make sure it’s succeeding but in your case your get all actors of class isn’t connected to anything. Just plug the pin from Destroy actor into Get all actors of class and it should work. Also, You want to quit the game when the player wins? That might be a bit harsh but I’m guessing it’s just for testing purposes?

Sorry for delayed response I’ve been working on other parts and didn’t see the update. Your advice worked great thank you. Yes quit game is just for test as win screen and main menu is yet to be built. Thanks again, Andy