Game load destroying enemies

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
Post Reply
Yama
Posts: 1
Joined: Sat Jun 11, 2022 4:52 am

Game load destroying enemies

Post 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}}"},
User avatar
Tony Li
Posts: 22195
Joined: Thu Jul 18, 2013 1:27 pm

Re: Game load destroying enemies

Post 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.
Post Reply