Hello, sorry I am completely new to unreal engine and am following a bunch of youtube tutorials. The problem that I am having is that when a player teleports to the checkpoint they have most recently gotten to, the item counter that I have created resets to 0. I do not want the item counter to reset, I just want the player to be able to teleport back to the checkpoint and continue the game. The premise of the game is it is a 3D platformer with three checkpoints, and you collect 5 fish to win. Any help would be appreciated!! (I can’t upload images or videos so I just put everything in a google drive folder, here is the link: UE5_Help - Google Drive)
Do you destroy your player when you teleport and respawn a new instance of him ?
You could afcourse save the item counter and load it on respawn. But you could bypass this if your player just teleports to the checkpoint without destroying the player at all but just teleport him to the new location. Even if he dies he can have this death animation but basicly he never get’s destroyed only teleported. If this is the case for you then you can try it.
Just create your index or float fish variable in the game instance set it as editable. Use Get Game Instance and cast to your game instance and set the variable there.
You can retrieve it very easily from the game instance by casting back to it and getting it and it won’t reset on you unless you close the game. That way you don’t have to change any of your respawning logic. Your player variables will reset every time you restart the player and those variables on it will go back to default, so unless they are just one offs then I wouldn’t put your fish in there.
Alternatively, you can use your custom player state to store the same variable, but it has some quirks to it.
The only thing to think of with the game instance is that if you change levels and want to start the fish index back to zero you’ll have to manually reset it back to zero. If you want it to persist even after closing the game then you’ll need to make a save game and store it there also.