Create Game Instance to Store Score Variable and Provide a Place to Access It, things in Game Instances are persistent and remain throughout the game.
**In your game Level Script/Blueprint add a variable reference to the Game Instance you created so you can easily access variables and functions in it. **
In your Game Instance add a Score variable of type Integer and create Add Score Function.
Create a Reset Score Function.
Create a Check Score Function.
Create a Get Current Score Function.
Here are the Function Blueprints.
Add Score Function:
Reset Score Function:
Check Score Function:
Get Current Score Function:
Create a Door Blueprint:
Create Door Animation, such as with a Matinee Actor or Timeline:
**Add a Matinee Actor variable to the Door Blueprint and create an event to play the animation when called, in the Details tab select your Open Door Matinee Actor containing your open door animation so it is linked with the Matinee Actor variable in the Door Blueprint so the Door Blueprint has access to the Matinee Actor in the level and the playback works.
**Now select the Door in the level and create a reference to it in the Level Script so the Level Script can access it and call the events, functions, or variables on it, then setup input to a test keyboard key like the T key, and compile and save everything after setting the Score Limit and Score Amount to add for each time the Add Score and Check Score functions are called.
Press Play and then press T key 4 times, you will see the score increment as it is printed to the screen, and once the T key has been pressed 4 times it will playback the open door animation once the score gets to 40. The score will automatically reset back to 0 and you can repeat the process.
The result is this Score 10, 20, and 30 on T Key 3 presses:
And on the 4th T key press for Score 40 it plays the door animation, which how I set my animation moves the door to the right a bit.:
The Unreal Engine Content Examples, the example Game Content and Templates, and online on YouTube are a good place to learn more, a lot of tutorials and examples are also on the official Unreal Engine YouTube channel, website, and in documentation online and the wiki.
If I had to give any good advice for a beginner, it would be try and keep things simple as much as possible and not overcomplicate, because we often get stuck and have tendency to focus so much on the details that the simple functionality for simple gameplay that is more complete could be done much faster with sticking to simple functionality, and it’s about what makes a game fun and enjoyable in the long run.