Hi, I am currently working on building a 2d sprite based RPG game. So far I’ve managed to solve any issues that have come up, but I’ve been working at this one for nearly a week and I am stumped.
The idea is that there is a player sprite you move around the over-world, and whenever it collides with an enemy sprite, a separate battle scene is loaded for a traditional 2d RPG battle, like those in some of the older Final Fantasy games. I can load my battle scene just fine, but whenever the battle ends and the scene closes, the player sprite returns to its original starting position in the over-world. I have two prefabs for the player, one for the player in the over-world and one for the player in the battle scene, since the battle and the over-world require very different scripts for the player to operate. I also have an object that I have named “God” that has a “DoNotDestroyOnLoad” function attached to it, making it persistent between scenes. This object tracks things such as player HP and other stats, and manages some other stuff as well.
What I would like is the game to save the position of the player sprite when it enters the battle, and then after the battle is complete reload the scene with the player at this position. Is this something that can be done with a binary formatter, (which is what I am using to save my data such as player HP and all that) or is there another way that I can do this? I’m honestly not sure what scripts to attach here to reference this, so I’m just going to kind of leave this open ended.
I really appreciate any help that I get in response to this question, thanks in advance to anybody who helps me solve this problem!