Friday, January 25, 2019

unity - Unity2D - Save everything in a scene before loading another and come back to it?


So I have am into this endless runner thing where everything is generated randomly from prefabs. Okay cool! But I am currently working on a bonus collectible which takes the player to another scene. After certain time, the player must reach at exactly the same position it left from.


But that's not the problem. I have figured out a way to save and load player's and camera's position using temporary prefabs.


My problem is : When the player collects the bonus thing in main scene and goes to the bonus scene and comes back, there's a sort of gltichiness or distortion in the game view. As if, the bonus scene is frozen and other scene is overlapping and everything is being stretched. But in inspector, everything including camera is in place.


In game view, on returning, the camera seems to be starting from beginning while in inspector its exactly where its supposed to be. Not only that, there's a lot of distortion, which I am 70% sure is because the level had to load all over again and there's no possible way of game knowing which prefabs were instantiated as they all are random.


Compiling up, my question is, how can I save everything in a scene before leaving and load it all again at once so it doesn't have to go through all of it again. Is there any less-complex way? I hope I have made my ques clear. Thank you.




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...