Collect items to end game

Hello,

I’m currently working on a small game for class where you play as a dog and you have to find all eight tennis balls lying around the level before time runs out, or else the game ends.

The only thing I’m having trouble figuring out is making it so that whenever the dog moves over a tennis ball and it vanishes (I already got that part down by putting a destroy actor node), it’s added to it’s collection and when you walk over eight in total, you get a “You win” screen.

Any help is appreciated, thank you.

I would create a variable (interger) in your dog blueprint and then when you pick up a ball cast to the dog put in a branch if it’s less than what you need add one once you reach your desired number call your end game event, hopefully that makes sense

This is what I’ve got in my blueprint for my character (the dog) and nothing seems to be happening when I move over the collectible.

I just realized I forgot to add the Add to Viewport node, I’m a moron…

Anyway, now that I walk over a ball, the “Win” widget shows, but it only does it when I pick up one tennis ball, which is not what I want, I want it to show when I get all eight. I’ve been trying to figure it out, but nothing is working.

Any help is appreciated thank you.

I attached an image to your previous comment that should help with that.

There are different ways to handle it but this is how i would most likely set it up.
I put the variable and Win event in the Dog BP and do the rest in the Ball BP on overlap with a collision Sphere,
Hopefully that Helps.

There are several different ways to do this, I did something similar in opening a door for a school project where I counted down how many keys were left in the level to open a door, to start I made the key (pickup) check for an overlap of anyone tagged friendly which is my player, then I casted to the game mode where I made a function which set my number of keys picked up by +1, then in the door I did a branch comparing how many keys are needed for that door to be open, from a do once node I then fired the function that this door served which was opening the door, for you that would fire off the end game sequence, however youve either done that or are planning on doing that.
The end goal is different but the logic between the two projects is so similar you would just have to slightly change a few easy values to match your goal.
Should not that the function is in the game mode because I needed its value to be seperate from the door and the key objects.
,

Ah I’m sorry about that, for some reason my comment didn’t go through right away when I submitted it…

But anyway, I tried this and it seems to work perfectly! Thank you so much!!

No stress, Happy i could help

This looks like what I need which is a similar scenario as OP. But quick question, is the top left blueprints put on key/keys blueprint. If so, why does (Actor has tag) say “key”… do you have the player with the tag “key” on it?..Second, the bottom left is written within the Function “Total Keys Picked Up” located in the Active GameMode, or is it in the Event Graph?..Sorry im still new to UE4 and just wanting to double check…For example I put a (Play Sound 2D ) after the Keys (Branch), but the sound doesnt play, but if I put it after the (Begin Overlap) it seems to play the sound correctly. So somewhere between its not working.