My NPC is now able to make her own way home to sleep and eat, even though there are closed doors and ladders, she can talk to the player and trade goods. My Goblin will patrol its territory and attack enemies who appear in it.
What I do is the blackboard tells the NPC what to do now (e.g., time to sleep, time to eat, time to work), and then the behavior tree will turn to the corresponding child behavior tree, which will drive the BTTask based on the blackboard variable values (e.g., open the door, close the door, walk to a location, climb ladders, etc.). The controller updates the blackboard data based on the current values of the character’s member variables. The character only provide some basic unit functionality.
So my rule is, the character will only provide the basic functionality, no complicated things will be implemented here, the controller provides the data for the blackboard, the behavior tree controls what the character does.
When I wanted to go further, I hit a roadblock on how to implement NPC to do certain things for quest. Just like in The Elder Scrolls V, after the player talks to the NPC, the NPC will walk into a room, then wait for the player to enter the room and ask the player to close the door, after which she opens a hidden door and enters the room.
I have thought of two ways, one is to create a new child behavior tree and add variables on the blackboard, adding logic to the new child behavior tree for the task. The downside of this way is that if the NPC is associated with many tasks, since the blackboard of the Unreal parent tree must provide all the variables for the child tree, so the number of variables on the blackboard becomes very very large. The second way is to add an extra task queue to the NPC for temporary tasks, which the NPC will execute first. What we need to do is to turn the quests that need to be done into tasks for the NPC to perform. However, the disadvantage of this way is that it is not easy to be interrupted. For example, when an enemy comes into view while the NPC is waiting for the player to enter the ruins together, he should pull out his sword to fight with the enemy.
Does anyone have experience? Thanks for any sharing