Hello!
I am making a sidescroller game and I have a door mesh at the end of the level. I want the door to be destroyed after 10 coins are been collected. I also want to have a counter which shows how many coins the player currently has. Please somebody help me to do this.
Thanks!
Proposal… …the door can be referenced on the level BP. The amount of coins is a variable on the character. The character has a dispatcher function which say communicates the number of coins the character currently is carrying. The level BP binds to the character’s dispatcher at BeginPlay. The bound event on the level BP checks for the number of coins to be 10 or greater. When this happens either the door is destroyed or hidden from the game.
Thoughts?
This is a huge topic to cover. First thing first, you need to apply the overlap event trigger, then UMG after that blueprint scripting (which comes first doesn’t matter). Each class need to be able to communicate with each other to send values.
Thanks for reply, but it will be fine if someone attach a picture with nodes, because I am total beginner… I would be very thankful…
Hey @slycrespo2!
If you intend for this to only work in level, what you are looking for is blueprint communication. You will need a variable that can be updated with a function (number of coins) and of course your widget counter. Here is a non-Epic affiliated tutorial on blueprint communication through setting up a health bar that is the exact same concepts:
Total coins overall is similar but will require a persistent variable that transfers over all levels.
I hope the above solution works for you!
attach a picture with nodes, because I am total beginner…
I’ll do you one better, have a look here:
There is a project attached and the script you need to look into is in the Player blueprint. If this needs to work on a per-level basis, the script can be moved to the level blueprint instead - this will allow you to reference the door easily, for example:
Namely:
i think there is dozens of great answers already, but I just wanted to say that this sort of thing is covered in many, many “beginner unreal tutorials” you can find all over the internet.
It is worth doing a couple because that will answer many questions that you don’t even know to ask yet. It’s a great way to jump start your learning. In the old days developers just had to learn everything through trial and error, which is powerful way to learn but slow.
With internet, now you can learn a ton from people who already figured out the basics, which can save you tons of time, so take advantage of it. As a beginner, try out lots of different tutorials, even if they are not seemingly related to exactly what you want to do.