PixelCrushers.DialogueSystem.RealisticFPSPrefab.UnregisterNPCOnDestroy Class Reference

If your NPC has a PersistentDestructible, it will be destroyed when you load a saved game in which it's been killed. More...

Inheritance diagram for PixelCrushers.DialogueSystem.RealisticFPSPrefab.UnregisterNPCOnDestroy:
Collaboration diagram for PixelCrushers.DialogueSystem.RealisticFPSPrefab.UnregisterNPCOnDestroy:

Detailed Description

If your NPC has a PersistentDestructible, it will be destroyed when you load a saved game in which it's been killed.

Add this script to make it gracefully unregister from RFPS's NPC Registry and NPC Spawner when being destroyed.

You must also edit the RFPS CharacterDamage.cs script in two places.

On line 7 (after "public class CharacterDamage : MonoBehaviour {") add:

public UnityEngine.Events.UnityEvent onDie;

On line ~180, change this section of the ApplyDamage method from:

//Kill NPC
if (hitPoints /= 0.0f){
    AIComponent.vocalFx.Stop();

to:

//Kill NPC
if (hitPoints /= 0.0f){
    onDie.Invoke(); // ADD THIS LINE!
    AIComponent.vocalFx.Stop();

This will add an OnDie() event. Add PersistentDestructible.OnDestroy to the event.


The documentation for this class was generated from the following file: