How do I make it so the player collecting all of the items in a level...

…will allow him or her to access an exit portal to the next level?

I’m making a ball rolling prototype as a means to learn Unreal Engine (as well as for a class assignment) and was wondering how collecting a certain number of orbs will then unlock an exit for the player to reach the next level. How can I do this with Blueprints?

I am just starting out, but I can follow along tutorials and such. I hope I have included enough information to get help.

Thanks for your time, all!

You might just want to use a branch and a condition for the portal. So that if the condition is true, the portal will be functioning and visible.

Hello aslankokb. So, if my limited knowledge is correct, then it’d be something like if 25 orbs have been collected, then the portal will be available to use?
How would I get that working in a Blueprint?

Hello,
Create a pick-up : a blueprint with a box as root and the mesh you want to use. In the event graph of your character, create an integer variable and add this graph :
bc23d6f45fa8deb86fe504ab8078ed340cee3f22.jpeg

@Fen In my opinion this is bad style.

  • The Bp_Pick class should be responsible for destroying itself. Because the player class is not interested in the lifetime of the object. In fact, the player class is not interested in anything in this example.
  • The score should be inside a game state class, because you may want to keep the score on death.
  • Checking if the goal is reached should be done in a BP_Door class. You may want to add multiple doors. Use a function to set the score in the game state and call an event dispatcher. The door can then bind an event to the dispatcher and can test every time the score changes.

@ : Dedicated to a beginner, a single screenshot of one usable working system easily understandable is in my opinion a really better solution. But thanks for the add. I am sure Phil32 will read all your advices and will discover a lot of new things with them.

@Phil32 ; From advices, i realize i didn’t point you to usefull links :
Samples and Tutorials for Unreal Engine | Unreal Engine 5.1 Documentation the tutorials (youtube and learn tab ones)
Unreal Engine 5.1 Documentation | Unreal Engine 5.1 Documentation the documentation
A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums The wiki

There are two things to think of here.

First: The player should have some form of indicating how many orbs they have picked up and this needs to be stored (and possibly replicated) on the character. This could be considered similar to health in some of the tutorials, the main difference will be it starting at 0.

Second: Your portal should have a trigger around it. The trigger will have an event that checks if the player has enough orbs, if not it can display a message or some other form of notification. If there is enough, you trigger the portal and do an animation or particle effect and load the next level.

This is relatively simple to do and if I was in front of my dev machine now I would knock up a Blueprint … but I think the object here for you is to learn … so I am hoping the concept above is enough to get you going.

Good luck and I hope this helps. 8-}

Trouble i have to store orb’s info in game instance is that it is stated that if player dies then orbs collected are always collected. If no, then you need to reset orb’s info which is automatic if info is in character. (In my idea i did a simple “open level” to back to start)

But i totally agree with and i would have set door event activated on player overlap in door itself, not in character.

Hello everyone. Thanks for your individual advice.
Forgive me if my questions are silly or dumb, or have already been answered. Currently, I’m learning the ins and outs of Unreal, so forgive if this question is too silly.
If I create a new game mode by creating a new Blueprint and clicking on Game Mode, will the examples that many of you shared for how to “program” the collecting of orbs still work? If not, what is my next step after creating a new Game Mode-type Blueprint?

Again, I’m sorry if these are dumb questions.

EDIT: To make what I’m asking perfectly clear, what should I do once I create a new Game Mode Blueprint? I have a Blueprint, but it’s currently empty.

When you created the Blueprint did you make it inherit from the Game Mode class?

The Blueprint is now empty and you now have to wire all your code in that you need.

You just got a ton of great advice that you probably don’t understand at all. I was there a few months ago, don’t worry about it. Here’s one of the best things you can do to start to make heads or tails of what these guys are talking about. Do the tutorials in this e-book:

http://www.kitatus.co.uk/master-the-art-of-unreal-engine-4-blueprints-book-1-hud-blueprint-basics-variables-making-small-projects-and-more/

The first one has a section on creating an animated texture, but you can skip that if you don’t want to learn the external tool he’s using. The UE4 stuff is invaluable though.

I think the author, Ryan, is a regular around these forums so you can probably get more info for searching around for his posts. The reason I suggest this is that Ryan’s book goes into the nitty-gritty detail regarding what to click, where to put stuff, etc. Once you get through this tutorial, you will have a much better understanding of the tools at your disposal and you’ll likely be able to re-read the advice above and understand it at least from a conceptual level.

This one tutorial was the gateway to being able to make an side-scrolling endless runner with procedurally generated levels, pick-ups, save games, etc. He doesn’t teach all that, but the fundamentals of the things he does teach make everything else start to make sense. Fill that in with all the great stuff on Epic/UE’s YouTube channel and you’ll be in great shape.

Good luck and have fun!

does your example not work then?

so does this mean the example you gave doesnt work if death is included? can you redo your example so it works? there are no more examples out there

im using 4.11 and i cant seem to be able to get up the “target orbs left” that sits in the first image. also, my “set” in the same image doesnt have a target pin on it

I don’t think that using tick is the good way to do this. It will burden the CPU for no reason. You should make function that will check how many orbs are in level and call that function everytime you pick up an orb. If the number is 0 or less then call function that will open portal. If you start using tick to do as simple system as this you will get trouble later. Trust me. I needed to organize lot of coding to get those important frames that tick took away, when i was developing for mobile platform. Always use functions or learn to use the Event dispatchers and when you pickup orb call the event you created. This way the CPU will not work until needed. With tick, it literally will check the values in every frame.

I would do something like this:

First create the GameState. GameState keeps track about every major thing in your game. You won’t get confused later when you know to check the GameState
1.png

In GameState i have two functions. Calculate orbs that will calculate orbs when map starts. This function is called in Event Begin Play. PickedUp Orb is a function that will be called everytime orb is picked
1.png

When picked orb it will check the remaining orbs and if they are 0 or less it will get the portal-actor (we know there is one so i just get all actors of class. You may want to do this differently) and call the function open portal that is created in Portal Blueprint.

Orb will only have trigger. When player overlaps it, function PickedUp orb is called from the GameState. Remember GameState will keep count of the orbs!

Portal will have one function called Open Portal. Remember this function is called from GameState too!

Beginning

Collected orbs

I would go a step further and use a Delegate aka EventDispatcher.

Why? Because I dislike the idea of using “GetAllActorsOfClass”.

The better solution would be creating an EventDispatcher, called for example “OnAllCoinsCollected”, inside of the GameState.

Inside of the door, OnBeginPlay, you then get the GameState, cast it and bind the “Open Door” Event to the “OnAllCoinsCollected” EventDispatcher.

Then you only need to call the EventDispatcher inside of the GameState and every Actor that bound an Event to it will call it.

Like this you can have all Actors react in a different way and you don’t need that ugly “GetAllActorsOfClass” node…