Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tracking status / position of certain (such as NPC / enemies) between scene changes

Discussion in 'Game Design' started by vdoggstudios, Jun 18, 2017.

  1. vdoggstudios


    Dec 22, 2016
    Hi All

    I have a couple of scenes.

    Scene 1 contains a few boxes which can be shot. These boxes (prototype enemies) have healthpoints and when shot their healthpoints decrease, they're also moved by the impact (AddForce).

    In this scene I also have a trigger which loads you to scene 2 when you stand on it.

    Scene 2 is just an empty scene with the exception of a trigger which loads scene 1 again.

    What I want to do is shoot some enemies / boxes to kill them, and move them around the level a bit - then enter the trigger to scene 2, then enter the trigger in scene 2 to go back to scene 1 and have the boxes in the same position as they were when I went to scene 2 (i.e. not in their default positions). I also want their healthpoints/status to persist.

    I'm just wondering what the theory is behind doing something like this?

    Would I have to store the position of each object in a static game control object (for example). Would I have to write a bit of code for every object? This would be ok for a few objects but could become unwieldy for a bigger game.

    Would it be possible to get the position and healthpoints of all objects with a certain tag/layer when switching scene and store this data in a file which can be read when loading the scene again?

    Any advice would be greatly appreciated. Thanks.
  2. Teila


    Jan 13, 2013
    You are asking about implementing mechanics in the game, not about design. You will get more help in the scripting forum than here or going to Learn and doing some tutorials.

    Please move your post so you can get the help you need.
    vdoggstudios and Kiwasi like this.