This example will be an extension of Example 2, so please firstly follow Example 2 before doing this one.
In this example we will add Saving Data when Subject is despawned and loading it when it is spawned back. And we will also use ShouldCalculateIsSeen option.
Let's say our AI Character have Health variable that should be kept even when its spawned/despawned.
In case we injured it, moved away from it and later came back to it, AI should still be injured.
This way whenever AI Character is being despawned, it will store Health state in data file, and will load it when it is spawned again.
- We want AI to be updated by subsystem right after its spawn, thus CanBeUpdatedBySubsystem is set to true.
- We don't want to allow subsystem to spawn/despawn this subject because we will do it manually, thus AllowSubsystremToDespawn is set to false.
- Priority doesn't matter in this case, it can be left at 0.
- Set DataClass that we have created before.
- We need 3 Optimization Layers - 1500/2500/3500 to optimize AI based on that.
- We want to adjust settings in optimization layers based on whether AI Character is visible by any Invoker or not, thus ShouldCalculateIsSeen is set to true.