Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    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.