I’m currently developing a racing game for mobile. What I want to do is that after the race the player will get points everytime the race is complete. Like EXP or SCORE or POINTS. Can you please help me how to do it ? Thanks in advance
Hey there @BeastNectus! So point systems are relatively simple in the short term, but leaning into EXP it gets to be a bit more involved. With a general per session point system, it’s pretty easy to just keep a variable that survives the play session. However, once that session is gone, so it the data. You’re also going to need to learn the saving/loading system so that players can retain their EXP/Points every time they open and close the application. To that end, I’ll link 2 tutorials, one of persistent points over levels which you’ll have to modify a bit for your specific need. Then a tutorial on the saving and loading system as well as it’s documentation.
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.
So the easy one first: Using the game instance to retain variables between levels. This will be necessary to keep your EXP when you change map:
Then you need to prepare a system for saving these variables and loading them when you open the game. Unreal’s built in save system can handle basic variables and structs of things decently easily! Matt shows a simple way of pulling this off for basic variables here:
Combining these two concepts would yield a basic EXP system that is retained over every play session.
What I want sir is that, After the laps finish the player will get pts like 2000pts per race and the pts they get will display in the TOP RIGHT of my MAP SELECTION.
Here in this video.
The BP of the game when its finish.
By combining both of those methods you can have a persistent point system. Did you have any questions about the implementation? I could attempt to make a little mockup for you to expand on, but the full system would definitely need to be worked on during full integration.
Yes, I would like to see how you implement it.
I can make a basic implementation for you, but to hook it up you’ll need to understand the save/load system well so I’d recommend studying it in the meantime.
Alright! So the system is complete, but you will have to hook it up to your racing systems yourself. First we’ll go over what’s included and the pieces, then how to hook them up.
Included:
RacingGameInstance - Holds the save logic and let’s your exp logic be persistent inside the game.
RacingSaveGame - Just a save object to hold the EXP variable (and anything else you want to save between play sessions)
RacingGameMode - Is currently automatically loading the EXP that was saved every time you start a new level. This logic could be replaced by making a menu to save and load or an autosave/load only when starting a new session.
Placeholder:
Placeholder Race Manager - Just an actor I have that simulates you finishing a race, adding the EXP, then Saving the EXP. This is just an example of how to use the system from your race logic. I don’t know your race logic so you’ll have to modify it to add what’s here.
Debug - Left some save logic on the player’s actor, it’s not meant to be used in game but there to test the system and made sure it worked. I’ll include it, but the save system works standalone now so it’s not hyper necessary unless you run into a bug.
Setup: First you need to make a new SaveGame object for your game, this needs to have all of the variables you want to be able to be saved. The only thing that will be in this BP are variables. It’s an object but not an actor so it doesn’t go in game.
That’s all that’s in it!
Next you need to make a new GameInstance, if you already have one, you can just hook this BP up right away.
Variables:
Here’s the BP:
The game instance is the meat of the system, is houses your EXP system and Save System. Any other actor can call to it to add EXP, save, load, delete date, etc. Since this is also the place the EXP lives, it handles it all in one.
Then remember to go to project settings and set it as your game instance in your project settings:
Optional: you can make the optional Autoloader in the Gamemode. All it does is load the EXP every new map. This can be quite disruptive if you want manual saves, since the EXP is in your game instance you don’t have to load every new level, only when you open the game, so you can just ignore this if you’d like. I used it for quick debugging.
Usage:
Any object needing to call the game instance will need to get it and cast to it. This is less efficient than just calling straight to the class but this can be slapped anywhere to do the job.
After that, all you need to do is make calls to the game instance for any of the events.
Miscellaneous:
Placeholder finish line - All it was there for is to add EXP at the end of races and then change level. I removed the change level for testing before.
Thank you so much sir for this, Sorry for the late reply I was not able to online for 6 days.
No worries and no rush to implement it. It’s fairly straight forward for the most part, but if you want to make modifications, read up on that save system documentation I sent before. If you have any questions about how any of it works feel free to ask! Once you get it implemented, you can go ahead and mark the solution!