How do I remove items from an array efficiently?

VagrantProfile
Tue, 06 Dec 2016 18:58:29 +0000
Editor Scripting

Hey Guys,

So I’m currently making a Pac-Man game in UE4. I want to make it, so that my level is over when Pac-Man collects all of the pellets I’ve placed around the level. I’ve created a Pellet Blueprint and have placed a couple hundred pellets around the maze. Now, I want to end the level when all pellets have been collected (my Pellet BP is set up to destroy each pellet when I overlap it.)

How can I set up a system to check that all pellets have been eaten? I THINK I’m on the right track? (see screenshot)

What I currently have in my LEVEL Blueprint is what you see below…I’m getting all actors of the Pellet class and finding out how many items are in that array upon Begin Play. What I DON’T know how to do is send a message from the Pellet BP to the Level BP to reduce that array by 1 with each pellet eaten. I thought to use Event Dispatchers, but couldn’t figure out how to set i up properly.

Any suggestions here on how I can end my level efficiently when all pellets are eaten?

2 posts - 1 participant