Kryat Docs Image
GOAP

Using GOAP Job

Overview

A GOAP Job is a set of predefined Capabilities where one capability is a collection of Goals, Actions, TargetKeys, WorldKeys, etc...

Add a new Job

  1. Add a new job to JobType enum, in /Code/~SharedREF/Alien/AlienJobs.cs
// /Code/~SharedREF/Alien/AlienJobs.cs
public enum JobType
{
    ...
 
    New, // Replace New to an appropriate job name/job title
}
  1. Add a new script NewJob.cs in /Code/AI/Job/
// /Code/AI/Job/NewJob.cs
namespace AI
{
    public class NewJob : AgentTypeFactoryBase
    {
        public override IAgentTypeConfig Create()
        {
            var factory = new AgentTypeBuilder(JobType.New.ToString()); // Set the JobType to your created JobType
 
            return factory.Build();
        }
    }
}
  1. Add a child object to GoapController ---
Add a child object to GoapController
  1. Add the new created script to the child object and validate
Add the new created script to the child object and validate
  1. Add the child object to the AgentTypeConfigFactories at GoapBehavior script in GoapController ---
Add the child object to the AgentTypeConfigFactories at GoapBehavior script in GoapController

Set Alien Job to the newly created job

  1. Create an instance of prefab Alien locates at /GameObject
  2. In the child object Code, switch the JobType to the desired job
In the child object: Code, switch the JobType to the desired job

Customize a Job

  1. In /Code/AI/Job, open a job script

  2. Add/Remove Capabilities in the script

  3. Add a new script NewJob.cs in /Code/AI/Job/

// /Code/AI/Job/NewJob.cs
namespace AI
{
    public class NewJob : AgentTypeFactoryBase
    {
        public override IAgentTypeConfig Create()
        {
            var factory = new AgentTypeBuilder(JobType.New.ToString());
            
            // Add shared capability
            factory.AddCapability<BaseCapability>();
            factory.AddCapability<IdleCapability>();
 
            // Add your custom capabilities here
            // E.g. Add combat capabilities to knights
            // ...
 
            return factory.Build();
        }
    }
}

On this page