Need help when items are collected its not getting the win condition

How the code is work is when all of the desired items are collected in the level its supposed to find that there is no more of the items left and its supposed to open a new level for the win condition but when all of them are collected its not working. Anyone know how I can fix this? I made it so its in the game mode to find the items in the level but how can I make it when there is no more it opens the new level

1 Like

How do you collect the items? What do you do to items you collect? Do you destroy them?

Hey @TinaBeana.1

It’s helpful if you can provide an image or code example to properly analyze the problem.

It depends on how you’re spawning the items.
Are they spawned from the beginning, are you spawning them during runtime, both, …?

To solve either case, you can make the “Pickable actors” tell the GameMode to add 1 on their begin play, and tell the GameMode to subtract 1 when they’re picked up before destroying them if that’s what you’re doing.

But it’d be easier to respond if you could provide more information.

yea the actor gets destroyed like the collection component is working its just not calling the win condition when all of the items are gone from the level

Do you spawn the items dynamically? Or are they already sitting pretty in the level?

Use common debugging.

Print the total ammount of items every time you pick one. Is it actually doing something and recognizing one of the items has been picked up, or does it never work?

Does it work but the “total” is off by one or something else?

Try using prints for every action that should be happening and for all the information that you can compare, like the total number of items on the scene when it starts. Then you may spot where the issue or issues are and fix them one by one.

the items spawn in the level

okay I’ll go try that
thank you

Could you clarify what that means? Are they already in the level? Or do you Spawn Actor From Class?


This would work in any scenario:

When spawning run-time, add to the counter and bind to the same event.

I have a spawner that spawns the items in the level in a blueprint and then the player collects all of the items that spawn and then the code finds how many of the items are in the level for example once everything is collected it says 10/10 but once all of them are collected I want another level to open for the win condition

As above then. You can skip the Get All + Loop part if you only spawn dynamically. So something close to:

Essentially, we add when spawning, and count down when stuff gets destroyed.

ok