Enemy ai still there after load game

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Enemy ai still there after load game

Post by hrohibil »

Hello

On my scene I added a destructible component to my enemy AI and my pickup gun.

When loading game after enemy is killed and gun is picked up then the gun is gone but the enemy is still there?

How does it work with that so the enemy is actually gone/dead when loading a saved game?

Cheers
User avatar
Tony Li
Posts: 21058
Joined: Thu Jul 18, 2013 1:27 pm

Re: Enemy ai still there after load game

Post by Tony Li »

If the enemy GameObject is destroyed or deactivated when the player kills it, add a DestructibleSaver component to it, and set a unique Key value.
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Enemy ai still there after load game

Post by hrohibil »

That is the component I already have on the AI..

When he dies, he plays the death animation and lies flat on the ground. Then I save my game and when I load again the ai is alive again
User avatar
Tony Li
Posts: 21058
Joined: Thu Jul 18, 2013 1:27 pm

Re: Enemy ai still there after load game

Post by Tony Li »

Does the Destructible Saver have a unique Key?

Are there any errors or warnings in the Console window?
hrohibil
Posts: 358
Joined: Thu Nov 04, 2021 12:50 pm

Re: Enemy ai still there after load game

Post by hrohibil »

Yes , inserted the name BOT in the key field.

On my AI it was set to remove the object after 30 seconds.
I saved my game while he played the death animation.

So that was the issue. Whe i saved the game after the 30 sec when AI was removed, then it works.
User avatar
Tony Li
Posts: 21058
Joined: Thu Jul 18, 2013 1:27 pm

Re: Enemy ai still there after load game

Post by Tony Li »

If your AI has a UnityEvent that's invoked when it dies, configure the UnityEvent to call DestructibleSaver.RecordDestruction. This way it will record the AI's death right away instead of having to wait 30 seconds.
Post Reply