Hi Tony,
Would it be possible to access and change the 'destroyed' bool in a destructible saver directly instead of actually destroying it? Or would that cause problems? When a monster is killed in my game the animation plays, falls over etc but then there may be some interaction between other monsters or characters that couldn't be done if the gameObject is destroyed immediately (spotting the corpse and investigating the area for example). I don't want the monster to respawn next time the level is loaded, but if the player saves/changes scene the monster will come back to life since the destructible saver hasn't triggered.
Is there a decent way to affect the destructible saver like this? Or would a custom saver make more sense? I am destroying the monster immediately under different circumstances, so using the same saver for this system would be super useful.
Cheers,
Rob
Destructible Saver question
Re: Destructible Saver question
Hi Rob,
Create a short subclass of DestructibleSaver that exposes the RecordDestruction() method. Example:
MyDestructibleSaver.cs
Use this instead of DestructibleSaver. When the enemy is killed, called the Killed() method.
Create a short subclass of DestructibleSaver that exposes the RecordDestruction() method. Example:
MyDestructibleSaver.cs
Code: Select all
using UnityEngine;
using PixelCrushers;
public class MyDestructibleSaver : DestructibleSaver
{
public void Killed()
{
RecordDestruction();
}
}
Re: Destructible Saver question
Excellent!
Works like a charm. I was starting to write code to force the game to destroy dying monsters before saving/scene changes ¬_¬. Figured this would be a FAR better solution if possible.
Cheers,
Rob
Works like a charm. I was starting to write code to force the game to destroy dying monsters before saving/scene changes ¬_¬. Figured this would be a FAR better solution if possible.
Cheers,
Rob
Re: Destructible Saver question
Great! Not that it helps you right this minute, but I'll make RecordDestruction() public in the next update so in the future people will be able to call it directly instead of having to use a subclass to access the method.