Page 1 of 1

Enemy ai still there after load game

Posted: Sat Nov 06, 2021 4:28 pm
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

Re: Enemy ai still there after load game

Posted: Sat Nov 06, 2021 5:16 pm
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.

Re: Enemy ai still there after load game

Posted: Sat Nov 06, 2021 5:42 pm
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

Re: Enemy ai still there after load game

Posted: Sat Nov 06, 2021 6:23 pm
by Tony Li
Does the Destructible Saver have a unique Key?

Are there any errors or warnings in the Console window?

Re: Enemy ai still there after load game

Posted: Sun Nov 07, 2021 1:24 pm
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.

Re: Enemy ai still there after load game

Posted: Sun Nov 07, 2021 1:35 pm
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.