Search Unity

Savegame : How to save positions and status of a lot of gameobjects

Discussion in 'Scripting' started by tet2brick, Mar 1, 2011.

  1. tet2brick

    tet2brick

    Joined:
    Jun 24, 2009
    Posts:
    77
    Hi,

    I have a lot of ennemies, medikit and ammo boxes as gameobject in my scene.

    I want to save their status (already dead/used), some variables (the hp of the ennemies for example) and their positions in the playerprefs to make a save/load system.

    I'm going to create a script with all the prefabs that can be instantiated (all the ennemies, medikits and ammoboxes) stored in an array.

    When the user save I search for all the object in the scene that are not dead/used, save the id of the prefab in playerprefs, its position etc

    If the user load the data, it will search extract it from playerprefs and instantiate all the prefabs listed.

    Do you think it's a good idea? Is there a better way of doing it?

    Thanks a lot :)