Carry Object over multiple scenes - Adventure Game

Hello everyone,

I try to make an adventure game like the good old LucasArts games.

I have got the movement for my character, but now I don’t know how to continue: My character should obtain a tagged gameobject (e.g. “Object1”) with OnCollision2D and should be able to carry this object over multiple scenes until the player presses the M key. Then the character should release this object (the item should spawn next to him).

The problem is it’s the first time I try to make this and I have no clue. If anyone has an idea or a script, I would be very grateful.


Hi Porcus,

What you need is DontDestroyOnLoad

Then you can enable or disable the same object as long as it is needed. You don’t need to spawn it as it will be there all the time, but you can deactivate it whenever you don’t need it (or don’t want to be seen on the screen).

Here’s the documentation on the code: Unity - Scripting API: Object.DontDestroyOnLoad

And here’s a nice official documentation about Data Persistence: Unity Connect