Page 1 of 1

Game load destroying enemies

Posted: Sat Jun 11, 2022 5:02 am
by Yama
Hi there. I'm having an issue where every time I load a game it destroys the enemies in my scene. I'm using dialogue manager for an increment on destroy type quest. I have 5 enemies set to wander on behaviour designer and everything works fine as far as destroying them and them being tracked on the quest. However whenever I save a game and then load it, all the enemies get destroyed and the quest gets completed. This is the message that shows up in the console in case it's related:

Save System: Storing in PlayerPrefs key Save1: {"m_version":0,"m_sceneName":"Level1","m_list":[{"key":"EnemyBoss (4)","sceneIndex":-1,"data":"{\"destroyed\":false,\"position\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}"},{"key":"EnemyBoss (3)","sceneIndex":-1,"data":"{\"destroyed\":false,\"position\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}"},{"key":"EnemyBoss (2)","sceneIndex":-1,"data":"{\"destroyed\":false,\"position\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}"},{"key":"EnemyBoss (1)","sceneIndex":-1,"data":"{\"destroyed\":false,\"position\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}"},{"key":"EnemyBoss","sceneIndex":-1,"data":"{\"destroyed\":false,\"position\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}"},

Re: Game load destroying enemies

Posted: Sat Jun 11, 2022 7:50 am
by Tony Li
Hi,

Are you changing scenes using any of these techniques? (If you're not using the Dialogue System, disregard the LoadLevel() command. The others all still apply.) Under the hood, these techniques call SaveSystem.BeforeSceneChange(). This method tells savers such as Increment On Destroy components that GameObjects are about to be destroyed when Unity unloads the level, so Increment On Destroy shouldn't count it as a kill.