Creating a New Persistent Reference AI

From RPG Creation Kit
Revision as of 13:40, 21 August 2023 by Silvematt (talk | contribs) (Created page with "In this tutorial we are going to see how you can add a new Persistent Reference AI. To know more about Persistent References, refer to this article. We will make a guard that will follow the ''WandererMerchant001'' on his path. == Creating the New NPC == To create the new guard, I'm going to duplicate the NPC "CityGuard001" and do the following changes: * Change its '''ID''' to '''WandererGuard001.''' * Change its '''Name''' to '''Wanderer...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In this tutorial we are going to see how you can add a new Persistent Reference AI.

To know more about Persistent References, refer to this article.


We will make a guard that will follow the WandererMerchant001 on his path.

Creating the New NPC

To create the new guard, I'm going to duplicate the NPC "CityGuard001" and do the following changes:

  • Change its ID to WandererGuard001.
  • Change its Name to Wanderer Guard.
  • Tick the Persistent Reference box.


Newprefai 1.png


Once you do that and click "Save", the AI will automatically be registered as a Persistent Reference and placed in the _PersistentReferences_ scene.

I'll go ahead and place the WandererGuard001 next to the WandererMerchant001 in the _PersistentReferences_ scene.

Setting up the NPC

Persistent Reference AI have two special fields that are visible from the RckAI Inspector, in the Entity tab in particular:

Newprefai 2.png


These represent the current location of the Persistent Reference.

There are two important things to remember:

  • If the WorldSpaceID set is an Exterior Worldspace, there is no need to set the "In Cell ID" field, the AI will be fully loaded if the player gets close to this AI.
  • If the WorldSpaceID set is an Interior WorldSpace, you need to provide the "In Cell ID" field.

Since our guard travels the Virrihael Exterior Worldspace, we only need to set the "InWorldSpaceID" to "VirrihaelWorldspace".

It is important to notice that at anytime you can change these fields to teleport the AI to new WorldSpaces and cells, which makes the use of Persistent Reference AI pretty convenient.

With that, you have your Persistent Reference set, and the next steps are only to set the behavior of the NPC.

Setting the NPC's Behavior

You could simply assign the NPC to follow the same path as the WandererMerchant001, but there may be few issues with it.

If the player talks to the WandererMerchant NPC, he will stop him while the guard would keep walking the path. Or if you talk to the guard, when you release him he will always walk at the same speed at the WandererMerchant, so they will be forever be out of synch.

We can assign to the WandererGuard001 the behavior "[BTree] [P] Follower Dynamic (MainTarget)", which will make the guard follow its main target and if the distance is significant, run to it. So it's perfect for our use case!

The only thing we need to do is to assign as the Guard's MainTarget the WandererMerchant, so he knows who to follow.

In the RckAI Inspector of the WandererGuard001, set the MainTarget to be the WandererMerchant001:

Newprefai 4.png