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.

  • \$\begingroup\$ Could you provide screenshots of the issue? It might help us better assist you. \$\endgroup\$ – Ben BearFish Oct 22 '15 at 18:23

PS: I haven't tested this but may be this can help. Can you do this. 1) make and empty Game object Positioned at (0,0,0). 2) Add all the existing Game objects in the Scene to this game object so this becomes the parent of all other Game objects. 3) write a script on this Game object and add this in the awake function

DontDestroyOnLoad (this);
  • \$\begingroup\$ I will try this. \$\endgroup\$ – Hardik Oct 24 '15 at 0:41

Do you really have to go to another scene?

It just seems like you can put both of your bonus level, and your classic level in the same scene, and then work on the camera/player position, translate it, lerp it, move it whatever way you like with no glitches or loading to worry about.

Also, make sure you're cleaning up anything that's not useful too!

  • \$\begingroup\$ Nope, that won't work. I really have to move to another scene for other reasons. It's not actually a "bonus" level but I added it to state an example :) \$\endgroup\$ – Hardik Oct 18 '15 at 4:28
  • 1
    \$\begingroup\$ I apologize if this comes out as rude, but what sort of reasons? The optimal way is to use the same scene. Explain to me why you "can't"? \$\endgroup\$ – Zee Oct 19 '15 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.