Difference between revisions of "NPCs Creation"

From RPG Creation Kit
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
In this tutorial, that comes after [[A First Look, Part 1]] and [[A First Look, Part 2]] we will see how we can add NPCs in the RPG Creation Kit and how they exist in the project.
In this tutorial, that comes after [[A First Look, Part 1]] and [[A First Look, Part 2]], we will see how we can add NPCs in the RPG Creation Kit and how they exist in the project.


The process is very easy and straightforward, so let's get right into it.
The process is very easy and straightforward, so let's get right into it.
Line 48: Line 48:
I'll leave everything untouched and switch to the "Face" tab, where I'll edit his face and select Hair and Eyes for him.
I'll leave everything untouched and switch to the "Face" tab, where I'll edit his face and select Hair and Eyes for him.


Next, in the "Inventory" tab you'll pick all the items you want this NPC to carry, and if he dies, to loot on his body.
== Inventory & Equipment ==
[[File:Npcc 1.png|thumb|The Inventory & Equipment of Uriel001|259x259px]]Next, in the "Inventory" tab you'll pick all the items you want this NPC to carry, and if he dies, to loot on his body.


[[File:Npcc 1.png|thumb|The Inventory & Equipment of Uriel001]]
You'll notice that the arrow [[File:Npc c 1.png]] will appear right to every item, the arrow is used to make the NPC equip the selected item, that will be present also in the "Equipped Items" list. You should '''only''' equip ARMOR and Weapons, and have only one weapon an armor piece equipped at time, other situations, such has having 2 sword in the Equipped list, have an undefined behaviour.
You'll notice that the arrow [[File:Npc c 1.png]] will appear right to every item, the arrow is used to make the NPC equip the selected item, that will be present also in the "Equipped Items" list. You should '''only''' equip ARMOR and Weapons, and have only one weapon an armor piece equipped at time, other situations, such has having 2 sword in the Equipped list, have an undefined behaviour.


I'll have him equip the Iron Set (Curiass, Gloves, Pants, Boots) and the Steel Greatsword:
I'll have him equip the Iron Set (Curiass, Gloves, Pants, Boots) and the Steel Greatsword as seen in this picture. You can add whatever else item you'd like to find on his body, golds, potions, food.
 
== Behaviour & Dialogue ==




Line 64: Line 66:
For the Current and Default dialogue, I'm going to set it to the "GenericEmpty" dialogue.
For the Current and Default dialogue, I'm going to set it to the "GenericEmpty" dialogue.


And we're done.
And we're done make sure to click on "SAVE", in the NPC list on the left the ID should have changed from "_NewRck_AI" to "Uriel001" or whatever else ID you used.
== Adding the NPC to the game ==
[[File:Npcs creation1.png|thumb|Uriel001 placed inside "Virrihael(0,-2)" celll.]]
[[File:Npcs creation1.png|thumb|Uriel001 placed inside "Virrihael(0,-2)" celll.]]
Click on "SAVE" and then on "SELECT PREFAB" on the top.


To find the prefab in the project, you can either search it in the "Project Window" by searching "[AI] Uriel001" or by clicking "Select Prefab" in the Rck AI Editor while the NPC you want to add is selected.


Put the prefab inside the scene and now you need to build an habit.
 
Select the prefab, throw him inside the scene and now you need to build an habit.


Everytime you change something inside a [[Cell]] that is accessible by ID, such as adding/removing AI, adding/removing [[NPC Action Point|NPC Action Points]], doors or any other element that has an ID, you need to '''[[Update the Cells|Update the Cell]]'''. You can do this by selecting the "'''CellInfo'''" GameObject inside the cell, and click in the inspector "'''Update Cell'''". What this will do, is to simply ensure the Cell is correctly configured, that every ID->Reference exists and every GameObject is at his place. Make sure to do that before going on.
Everytime you change something inside a [[Cell]] that is accessible by ID, such as adding/removing AI, adding/removing [[NPC Action Point|NPC Action Points]], doors or any other element that has an ID, you need to '''[[Update the Cells|Update the Cell]]'''. You can do this by selecting the "'''CellInfo'''" GameObject inside the cell, and click in the inspector "'''Update Cell'''". What this will do, is to simply ensure the Cell is correctly configured, that every ID->Reference exists and every GameObject is at his place. Make sure to do that before going on.
Line 94: Line 99:


Now [[Loading the game|load the game]] again from a savegame '''prior''' before you meet the NPC, and you when you will arrive to his Cell, he should walk to the chari and then sit on it. When he's sit, save a game and load back that savegame, and make sure he sits again as soon as he's loaded. If he do, you've successfully completed this tutorial!
Now [[Loading the game|load the game]] again from a savegame '''prior''' before you meet the NPC, and you when you will arrive to his Cell, he should walk to the chari and then sit on it. When he's sit, save a game and load back that savegame, and make sure he sits again as soon as he's loaded. If he do, you've successfully completed this tutorial!
[[File:Npc c8.png|left|thumb|351x351px|The NPC walking to the Chair.]]
[[File:Npcc 9.png|none|thumb|312x312px|The NPC sitting on the Chair.]]


== Troubleshooting ==
== Troubleshooting ==
If the NPC sits upon reloading the game, you can ignore this section, you've did everything right. Althrough it could be useful to learn the most common mistakes you can make and errors they generate while creating an NPC.
If the NPC sits upon reloading the game, you can ignore this section, you've did everything right. Although it could be useful to you to learn the most common mistakes you can make and errors they generate while creating an NPC.
 
=== I'm sure I've set the NPC Behaviour and Action Point, but he doesn't walk to the Chair. ===
This could happen because you've loaded a savegame that was made '''prior''' to the edit of the Behaviour/Action Point where the NPC was loaded. When you create a savegame, the state of every loaded NPC gets saved on the file and will be loaded next time you use that savegame. In our case if you saved before editing the instance, the savefile knew that Uriel had the "EmptyState" Behaviour, and will load back to that.
 
'''Solution:''' load a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.
 
=== I receive in the console "Object you want to instantiate is null". ===
This error is shown most likely because some [[Databases|Database]] failed to Update or was not updated at all when we've added new game content.
 
'''Solution:''' To fix this error, Update all Databases, click on the "RPG Creation Kit" menu at the top and select "Update all Databases" while the Game is not running. Then load a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.
 
=== The NPC walks to the chair and sits, but when I save and load he will not sit back. ===
This happens because the NPC hasn't been registered to the cell "Virrihael(0,-2)", because you've probably forgot to '''[[Update the Cells|Update the Cell]]''' after adding the NPC to the scene.
 
'''Solution:''' Load the cell "Virrihael(0,-2)" and select the "'''CellInfo'''" GameObject, then click in the inspector "'''Update Cell'''". Then load a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.
 
=== Something else that is not listed here happens. ===
If you're having a result that is not listed above, try both '''Updating the Cell''', '''Updating all Databases''' and loading a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.

Latest revision as of 10:35, 19 February 2022

In this tutorial, that comes after A First Look, Part 1 and A First Look, Part 2, we will see how we can add NPCs in the RPG Creation Kit and how they exist in the project.

The process is very easy and straightforward, so let's get right into it.

NPCs as Prefabs

The "Rck AI" Inspector that appear while you have an NPC selected inside a scene.

In the RPG Creation Kit, NPCs exists as prefabs inside your project. To have NPCs inside your cells, you may place those prefabs directly in the corresponding scenes or you may instantiate them at runtime.

Unless for specific reasons (as we've seen for the Thief in the previous tutorial) you should always place them while composing your scenes.

If you have an NPC inside your scene, you're able to assign more settings to him by using the Inspector, as compared to the Rck AI Editor Nevertheless, if you are going to modify something that is present inside the Rck AI Editor, you should always do it from there, as it will edit the Prefab and not the instance you have in the scene.


Before going foward, focus on the Cell View and open the scene "Virrihael(0,-2)", we are going to place the NPC by the lake and make him sit on the chair that's there.




Creating the NPC

If you want to create a new NPC, you are always going to use the Rck AI Editor. You can open it by clicking on the top-menu "RPG Creation Kit -> Rck AI Editor".

There are two ways you can create an NPC, from scratch or by duplicating an existing NPC. We are going to create him from scratch.

Right click in the left-list, while not hoovering on a button, and select "New":

Crnp1.png


This will add a new element in the list at the very top of it, named "_New_RckAI". Click on it and let's configure it.

Select the Entity ID, which is the ID of this NPC and pick a name for him.

I'll have:

ID: Uriel001

Name: Uriel

If you're wondering why I always add '001' at the end of every ID, it's because of two things, the first one is that If I look at it I can instantly tell it is an ID, the second thing is that during the creation of your game you may have variations of the same NPC, as it happens for "Ryan" in the Demo. So you can differentiate versions of NPCs with the number '001', '002'...

Next, pick the Race, at this point you should only have one, unless you created new races. Select "Human" and take a look at the window.

I'm, gonna leave the "IsMale" cheked since my NPC will be a male, the rest is really upon to you, see the explaination for each field in the Rck AI Editor article.

I'll leave everything untouched and switch to the "Face" tab, where I'll edit his face and select Hair and Eyes for him.

Inventory & Equipment

The Inventory & Equipment of Uriel001

Next, in the "Inventory" tab you'll pick all the items you want this NPC to carry, and if he dies, to loot on his body.

You'll notice that the arrow Npc c 1.png will appear right to every item, the arrow is used to make the NPC equip the selected item, that will be present also in the "Equipped Items" list. You should only equip ARMOR and Weapons, and have only one weapon an armor piece equipped at time, other situations, such has having 2 sword in the Equipped list, have an undefined behaviour.

I'll have him equip the Iron Set (Curiass, Gloves, Pants, Boots) and the Steel Greatsword as seen in this picture. You can add whatever else item you'd like to find on his body, golds, potions, food.

Behaviour & Dialogue

In next tab, you're asked to select the Behaviour and Dialogue of the NPC.

For the Behaviour, as we said previously we want him to sit on the chair. Since this behaviour is cell-dependent (the chair he has to sit on exists only in the Virrihael(0,-2) cell, we'll set it into the Instance of the prefab later. For now, select as purpose Behaviour "[BTree][P] EmptyState". This means that everytime the NPC will be instantiated, unless specifically changed, he will have the EmptyState behaviour.

For the Combat Behaviour, select "Full Combat_Forced".

For the Current and Default dialogue, I'm going to set it to the "GenericEmpty" dialogue.

And we're done make sure to click on "SAVE", in the NPC list on the left the ID should have changed from "_NewRck_AI" to "Uriel001" or whatever else ID you used.

Adding the NPC to the game

Uriel001 placed inside "Virrihael(0,-2)" celll.

To find the prefab in the project, you can either search it in the "Project Window" by searching "[AI] Uriel001" or by clicking "Select Prefab" in the Rck AI Editor while the NPC you want to add is selected.


Select the prefab, throw him inside the scene and now you need to build an habit.

Everytime you change something inside a Cell that is accessible by ID, such as adding/removing AI, adding/removing NPC Action Points, doors or any other element that has an ID, you need to Update the Cell. You can do this by selecting the "CellInfo" GameObject inside the cell, and click in the inspector "Update Cell". What this will do, is to simply ensure the Cell is correctly configured, that every ID->Reference exists and every GameObject is at his place. Make sure to do that before going on.


Great, now let's load the game and reach that Cell (just go South from the City gates).

Uriel001 inside the game.

You can see that you will be able to do with him most of the Interactions you've done with others in the Demo, because that's it, that's how NPCs are created and added in the world. You can talk with him, he will look at you and if you attack him he will fight back.

However, you'll notice that he's standing still and not sitting on the Chair we made for him. That's because we've set him the "EmptyState" Behaviour, and we said we want to modify the instance of the prefab, not the prefab itself.


So let's go ahead and make him sit on the Chair. load up again the "Virrihael(0,-2)" cell and focus on him, then let's take a look at the RckAI Inspector. Switch to the "Behaviour" tab, because that's what we need to modify and let's change his Purpose Behaviour to be "SBTP_UseCurrentActionPoint". This Purpose Behaviour will make the NPC, use his Current Action Point.


Perfect, the last thing to need to do is to choose his Current Action Point, we'll do that in the "Movements" tab, scroll down to "NPCActionPoint" and select the "WoodenChair..." that appears in the list.

Npcc 6.png Npcc 7.png


Save the scene and we're done.

Now load the game again from a savegame prior before you meet the NPC, and you when you will arrive to his Cell, he should walk to the chari and then sit on it. When he's sit, save a game and load back that savegame, and make sure he sits again as soon as he's loaded. If he do, you've successfully completed this tutorial!

The NPC walking to the Chair.
The NPC sitting on the Chair.


Troubleshooting

If the NPC sits upon reloading the game, you can ignore this section, you've did everything right. Although it could be useful to you to learn the most common mistakes you can make and errors they generate while creating an NPC.

I'm sure I've set the NPC Behaviour and Action Point, but he doesn't walk to the Chair.

This could happen because you've loaded a savegame that was made prior to the edit of the Behaviour/Action Point where the NPC was loaded. When you create a savegame, the state of every loaded NPC gets saved on the file and will be loaded next time you use that savegame. In our case if you saved before editing the instance, the savefile knew that Uriel had the "EmptyState" Behaviour, and will load back to that.

Solution: load a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.

I receive in the console "Object you want to instantiate is null".

This error is shown most likely because some Database failed to Update or was not updated at all when we've added new game content.

Solution: To fix this error, Update all Databases, click on the "RPG Creation Kit" menu at the top and select "Update all Databases" while the Game is not running. Then load a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.

The NPC walks to the chair and sits, but when I save and load he will not sit back.

This happens because the NPC hasn't been registered to the cell "Virrihael(0,-2)", because you've probably forgot to Update the Cell after adding the NPC to the scene.

Solution: Load the cell "Virrihael(0,-2)" and select the "CellInfo" GameObject, then click in the inspector "Update Cell". Then load a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.

Something else that is not listed here happens.

If you're having a result that is not listed above, try both Updating the Cell, Updating all Databases and loading a savegame that was made before meeting Uriel (or even just loading his cell) or create a new savegame.