### Register Agents and Entities with Utility World - C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityWorld/UtilityEntity Shows how to register multiple 'UtilityAgentController' and 'UtilityEntityController' instances with a 'UtilityWorldController' in Unity. The 'AgentsPlacedInSceneDemo' class iterates through lists of agents and charge stations, calling their respective 'Register' methods with the world controller. This setup is typically done in the 'Start' method to ensure entities are ready when the game begins. ```csharp public class AgentsPlacedInSceneDemo : MonoBehaviour { [SerializeField] private UtilityWorldController world; [SerializeField] private List agents; [SerializeField] private List chargeStations; private void Start() { foreach (UtilityAgentController agent in agents) { agent.Register(world); } foreach (UtilityEntityController chargeStation in chargeStations) { chargeStation.Register(world); } } } ``` -------------------------------- ### C# OnGetRawInput Function Signature Update (v1 to v2) Source: https://uintel-go.utilityworlds.com/Documentation/UpgradeGuide Illustrates the change in the `OnGetRawInput` function signature required when upgrading from Utility Intelligence v1 to v2. The `InputContext` parameter now requires the `in` keyword. ```csharp protected override int OnGetRawInput(InputContext context) ``` ```csharp protected override int OnGetRawInput(in InputContext context) ``` -------------------------------- ### Create Custom Target Filter (C#) Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/TargetFilters Demonstrates how to create a custom target filter by defining a new class that inherits from `TargetFilter` and overriding the `OnFilterTarget` method. This example filters targets based on their `ChargeStationType`. ```csharp public class ChargeStationFilter : TargetFilter { public ChargeStationType Type; protected override bool OnFilterTarget(UtilityEntity target) { return target.EntityFacade is ChargeStation station && station.Type == Type; } } ``` -------------------------------- ### Add Unsupported Variable Type at Runtime in C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/Blackboard Demonstrates how to add a Blackboard variable at runtime, specifically for types that are not directly serializable by the editor. This example shows adding a list of `Transform` objects to a `TransformListVariable`. ```csharp public class PatrolWaypoints : MonoBehaviour { public List Waypoints; private void Start() { Character character = GetComponent(); var blackboard = character.Entity.Intelligence.Blackboard; var waypointsVariable = blackboard.GetVariable(BlackboardVariableNames.Waypoints); waypointsVariable.Value = Waypoints; } } ``` -------------------------------- ### Custom Entity Facade - C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityWorld/UtilityEntity Demonstrates how to create a custom 'UtilityEntityFacade' by inheriting from the base class. This example, 'ChargeStation', adds specific fields like 'type', 'chargeRadius', and 'chargePerSec', and exposes them through public properties. Custom facades allow entities to hold and expose unique data relevant to their function. ```csharp public class ChargeStation : UtilityEntityFacade { [SerializeField] private ChargeStationType type; [SerializeField] private float chargeRadius; [SerializeField] private float chargePerSec; public ChargeStationType Type => type; public float ChargeRadius => chargeRadius; public float ChargePerSec => chargePerSec; } ``` -------------------------------- ### Start Cooldown Timer Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Starts a cooldown period. The CooldownStartTime variable is updated to track the start of the cooldown, used by other tasks to determine if the agent is currently in a cooldown state. ```C# public class StartCooldown : ActionTask { public class StartCooldownData { public float CooldownDuration; } protected override void OnStart() { AgentController.SetVariable("CooldownStartTime", Time.time); } protected override UpdateStatus OnUpdate() { // Cooldown is considered active until explicitly stopped or duration passes // This task might just mark the start and rely on other tasks to check duration return UpdateStatus.Success; // Or Running if it needs to be active for a duration } } ``` -------------------------------- ### Move to Target with NavMeshAgent Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Uses NavMeshAgent to move to a target. The target's position is set only once at the start. Returns UpdateStatus.Success when the agent reaches the target, otherwise returns UpdateStatus.Running. ```C# public class MoveToTarget : ActionTask { public class MoveToTargetData { public Transform Target; } private NavMeshAgent navMeshAgent; protected override void OnStart() { navMeshAgent = AgentController.GetComponent(); if (Data.Target != null) { navMeshAgent.SetDestination(Data.Target.position); } } protected override UpdateStatus OnUpdate() { if (navMeshAgent != null && !navMeshAgent.pathPending && navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance) { return UpdateStatus.Success; } return UpdateStatus.Running; } } ``` -------------------------------- ### Define DistanceToTargetInput using Input Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/Inputs This example demonstrates how to create a custom input by inheriting from 'Input' and overriding 'OnGetRawInput' to calculate the distance between the agent and its target. It specifically ignores the Y-axis for distance calculation. ```csharp public class DistanceToTargetInput : Input { protected override float OnGetRawInput(in InputContext context) { var currentPos = AgentFacade.Position; var targetPos = context.TargetFacade.Position; currentPos.Y = 0; targetPos.Y = 0; return Vector3.Distance(currentPos, targetPos); } } ``` -------------------------------- ### Create Utility Agent Facade (C#) Source: https://uintel-go.utilityworlds.com/Documentation/UtilityWorld/UtilityAgent Example of creating a custom Utility Agent Facade by inheriting from UtilityAgentFacade. This component interacts with the Utility Agent's GameObject and provides access to its properties and components. ```csharp public class Character : UtilityAgentFacade { [SerializeField] private Team team; private CharacterEnergy energy; private CharacterHealth health; private NavMeshAgent navMeshAgent; private Rigidbody rigidBody; public Team Team => team; public NavMeshAgent NavMeshAgent => navMeshAgent; public Rigidbody RigidBody => rigidBody; public CharacterHealth Health => health; public CharacterEnergy Energy => energy; private void Awake() { navMeshAgent = GetComponent(); rigidBody = GetComponent(); health = GetComponent(); energy = GetComponent(); } } ``` -------------------------------- ### Get Utility Entity by ID - C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityWorld/UtilityEntity Illustrates how to retrieve a 'UtilityEntity' from a 'UtilityWorldController' using its unique 'Entity Id'. After an entity is registered, it receives an ID. This code snippet shows how to get that ID and then use the 'world.GetEntity(entityId)' method to fetch the entity object. This is useful for accessing entities from different parts of the code without direct references. ```csharp int entityId = entity.Id; var entity = world.GetEntity(entityId); ``` -------------------------------- ### C# OnCalculateNormalizedInput Signature Update (v1 to v2) Source: https://uintel-go.utilityworlds.com/Documentation/UpgradeGuide Shows the modification needed for the `OnCalculateNormalizedInput` function when upgrading from Utility Intelligence v1 to v2. The `InputContext` parameter is replaced with `in InputNormalizationContext`. ```csharp protected override float OnCalculateNormalizedInput(int rawInput, InputContext context) ``` ```csharp protected override float OnCalculateNormalizedInput(int rawInput, in InputNormalizationContext context) ``` -------------------------------- ### InputFromSource with InputSource Parameter Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/Inputs This abstract class defines a base for inputs that retrieve data from a source (Self or Target). It includes an 'InputSource' enum to specify which entity to get the input from and a 'GetInputSource' method to retrieve the correct UtilityEntity. ```csharp public abstract class InputFromSource : Input { public InputSource InputSource; protected UtilityEntity GetInputSource(in InputContext context) { if (InputSource == InputSource.Self) return Agent; if (InputSource == InputSource.Target) return context.Target; return null; } } ``` -------------------------------- ### Data Structure Comparison: Utility Intelligence v1 vs v2 Source: https://uintel-go.utilityworlds.com/Documentation/UpgradeGuide Compares the data structures of Utility Intelligence in v1 and v2. Version 2 reorganizes 'Decisions' by moving them from 'DecisionMakers' to the outer scope. ```json { "$type": "CarlosLab.UtilityIntelligence.UtilityIntelligenceModel", "DecisionMakers": [ { "$type": "CarlosLab.UtilityIntelligence.DecisionMakerModel", "Id": "6f5616e5-a485-4c3b-9bc4-1eb1f10530fa", "Name": "Warrior", "Decisions": [ { "$type": "CarlosLab.UtilityIntelligence.DecisionModel", "Id": "a36b4f16-d8d0-4069-94ab-925828eb3c7d", "Name": "MoveToHealthStation", ... } ], ... } ], ... } ``` ```json { "$type": "CarlosLab.UtilityIntelligence.UtilityIntelligenceModel", "DecisionMakers": [ { "$type": "CarlosLab.UtilityIntelligence.DecisionMakerModel", "Id": "6f5616e5-a485-4c3b-9bc4-1eb1f10530fa", "Name": "Warrior", ... } ], "Decisions": [ { "$type": "CarlosLab.UtilityIntelligence.DecisionModel", "Id": "a36b4f16-d8d0-4069-94ab-925828eb3c7d", "Name": "MoveToHealthStation", ... } ], ... } ``` -------------------------------- ### Define HealthInput using InputFromSource Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/Inputs This example shows how to create a custom input by inheriting from 'InputFromSource' to retrieve the health of the input source (Self or Target). It checks if the source is a Character and returns its Health, otherwise returns 0. ```csharp [Category("Examples")] public class HealthInput : InputFromSource { protected override int OnGetRawInput(in InputContext context) { UtilityEntity inputSource = GetInputSource(in context); if (inputSource.EntityFacade is Character character) { return character.Health; } return 0; } } ``` -------------------------------- ### Add Parameter to Target Filter (C#) Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/TargetFilters Illustrates how to add parameters to a custom target filter to customize its filtering behavior. Public fields declared in the target filter class serve as parameters. This example filters targets based on the `Team` property of a `Character` entity. ```csharp public class TeamFilter : TargetFilter { public Team Team; protected override bool OnFilterTarget(UtilityEntity target) { if (target.EntityFacade is Character targetCharacter) { return targetCharacter.Team == this.Team; } return false; } } ``` -------------------------------- ### Reference Blackboard Variable in Action Task (C#) Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/Blackboard Shows how to reference a Blackboard variable within an action task. A public field of type `VariableReference` is declared, allowing easy assignment of a Blackboard variable through the editor. This example uses a `float` variable for movement speed. ```csharp [Category("NavMeshAgent")] public class MoveToTarget : NavMeshActionTask { public VariableReference Speed = 5; protected override void OnStart() { navMeshAgent.speed = Speed; MoveToTarget(); } protected override UpdateStatus OnUpdate(float deltaTime) { if (HasArrived()) return UpdateStatus.Success; return UpdateStatus.Running; } protected override void OnEnd() { StopMove(); } } ``` -------------------------------- ### Blackboard Variable Retrieval in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Demonstrates the usage of Blackboard.TryGetVariable() for safely retrieving variables from the Blackboard. This method helps in avoiding errors when a variable might not exist. ```csharp Blackboard.TryGetVariable("variableName"); ``` -------------------------------- ### ScriptableObject Variables in Blackboard (C#) Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Introduces `ScriptableObjectVariable` and `ScriptableObjectListVariable` for storing ScriptableObjects within the Blackboard system. This enhances data management capabilities for game objects. ```csharp public class ScriptableObjectVariable { // Implementation details } public class ScriptableObjectListVariable { // Implementation details } ``` -------------------------------- ### Caching for Decisions and Considerations in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Introduces toggles like HasNoTarget and EnableCachePerTarget to enable caching for decisions, considerations, input normalizations, and inputs. This prevents redundant calculations and improves performance. ```csharp // Example of enabling cache for a decision decision.EnableCachePerTarget = true; // Example of checking if a target is not required for a decision if (decision.HasNoTarget) { // Handle case where no target is needed } ``` -------------------------------- ### Get Component from GameObject Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Retrieves a component of a specified type attached to the GameObject. This is a generic function applicable to various component types. ```C# public T GetComponent() where T : Component; public T GetComponentInChildren() where T : Component; ``` -------------------------------- ### Coroutine Management Functions Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Provides functions to start, stop, and manage coroutines from action tasks. These are essential for handling asynchronous operations within agent behaviors. ```C# void StartCoroutine(string methodName); Coroutine StartCoroutine(IEnumerator routine); Coroutine StartCoroutine(string methodName, object value); void StopCoroutine(string methodName); void StopCoroutine(IEnumerator routine); void StopAllCoroutines(); ``` -------------------------------- ### Basic Blackboard Input Types in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Adds a set of basic input types for retrieving values from the Blackboard. These include integer, boolean, float, double, long, and various vector types, simplifying data access within the framework. ```csharp public class BasicInputInt {} public class BasicInputBool {} public class BasicInputFloat {} public class BasicInputDouble {} public class BasicInputLong {} public class BasicInputVector2 {} public class BasicInputVector3 {} public class BasicInputVector2Int {} public class BasicInputVector3Int {} ``` -------------------------------- ### Entity Enable/Disable Methods in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Methods for safely enabling and disabling utility entities. These are available on EntityController and EntityFacade, offering granular control over entity functionality without affecting their active state. ```csharp public class EntityController { public void SetEnabled(bool enable) { // Implementation details } } public class EntityFacade { public void SetEnabled(bool enable) { // Implementation details } } ``` -------------------------------- ### LayerMask Serialization in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Explains the support for serializing LayerMask fields, allowing them to be edited in the Utility Intelligence Editor and saved to Intelligence Assets via JSON. ```csharp // Assume LayerMask field named 'targetLayerMask' // In the Utility Intelligence Editor, you can now directly edit targetLayerMask. // Changes are serialized to JSON and saved. ``` -------------------------------- ### Enable/Disable Utility Entities in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Provides methods for safely enabling and disabling utility entities within the project. These methods are part of the EntityController and EntityFacade classes. ```csharp EntityController.Enable(); EntityController.Disable(); EntityFacade.Enable(); EntityFacade.Disable(); ``` -------------------------------- ### Serialization of Generic Types in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Illustrates the change in serialization format for generic types between versions 2.0.x and 2.1.0. This change affects how types like `VariableReference` are represented in serialized data. ```csharp // Version 2.0.x serialization format // CarlosLab.Common.VariableReference`1[[System.Int32]] // Version 2.1.0 serialization format // CarlosLab.Common.VariableReference`1[System.Int32] ``` -------------------------------- ### Entity Information Properties in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Properties to retrieve the status and information of utility entities. These properties, available on EntityController and EntityFacade, provide insights into whether an entity is registered, active, enabled, or destroyed. ```csharp public class EntityController { public bool IsRegistered { get; } public bool IsActive { get; } public bool IsEnabled { get; } public bool IsDestroyed { get; } } public class EntityFacade { public string Id { get; } public bool IsRegistered { get; } public bool IsEnabled { get; } public bool IsDestroyed { get; } } ``` -------------------------------- ### Filter Target by Team - C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityWorld/UtilityEntity Example of a TargetFilter that checks if the target entity belongs to a different team than the agent. It accesses the EntityFacade of both the agent and the target, casting them to 'Character' to compare their 'Team' properties. This filter is useful for ensuring agents do not target allies. ```csharp public class OtherTeamFilter : TargetFilter { protected override bool OnFilterTarget(UtilityEntity target) { if (target.EntityFacade is Character targetCharacter) { Character myCharacter = AgentFacade as Character; return myCharacter.Team != targetCharacter.Team; } return false; } } ``` -------------------------------- ### Entity Activation/Deactivation Methods in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Provides methods to safely activate and deactivate utility entities. These methods are part of EntityController and EntityFacade, ensuring controlled state management. They replace the unsafe GameObject.SetActive() for entity state manipulation. ```csharp public class EntityController { public void SetActive(bool active) { // Implementation details } public void Activate() { // Implementation details } public void Deactivate() { // Implementation details } } public class EntityFacade { public void SetActive(bool active) { // Implementation details } public void Activate() { // Implementation details } public void Deactivate() { // Implementation details } } ``` -------------------------------- ### Create a Generic InRange Normalization - C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/InputNormalizations Provides a base abstract class 'InRangeNormalization' for creating input normalizations that operate within a defined range. It includes public fields for 'MinValue' and 'MaxValue'. Concrete implementations like 'InRangeNormalizationFloat' and 'InRangeNormalizationInt' override the 'OnCalculateNormalizedInput' method to perform the actual range mapping. ```csharp public abstract class InRangeNormalization : InputNormalization { public VariableReference MinValue; public VariableReference MaxValue; } [Category("Range")] public class InRangeNormalizationFloat : InRangeNormalization { protected override float OnCalculateNormalizedInput(float rawInput, in InputNormalizationContext context) { var diff = MaxValue - MinValue; if (diff <= 0.0f) return 0.0f; float normalizedInput = (rawInput - MinValue) / (diff); return normalizedInput; } } [Category("Range")] public class InRangeNormalizationInt : InRangeNormalization { protected override float OnCalculateNormalizedInput(int rawInput, in InputNormalizationContext context) { var diff = MaxValue - MinValue; if (diff <= 0) return 0.0f; float normalizedInput = (float)(rawInput - MinValue) / (diff); return normalizedInput; } } ``` -------------------------------- ### BasicInput with VariableReference Parameter Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/Inputs This abstract class provides a base for inputs that use a reference to a variable. It includes a 'InputValue' field of type 'VariableReference' and overrides 'OnGetRawInput' to return the referenced variable's value. ```csharp public abstract class BasicInput : Input { public VariableReference InputValue; protected override T OnGetRawInput(in InputContext context) { return InputValue.Value; } } ``` -------------------------------- ### Add Blackboard GetVariable in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v1 Illustrates the initial implementation of the `GetVariable()` function for the Blackboard in C#, as introduced in version 1.0.10. This function allows for retrieving Blackboard variables using the value type (`TValue`). ```csharp public void TestBlackboard() { var blackboard = characterFacade.Entity.Intelligence.Blackboard; var sightRadiusVariable = blackboard.GetVariable("SightRadius"); sightRadiusVariable.Value = 30; } ``` -------------------------------- ### Applying Category Attribute to Inputs in C# Source: https://uintel-go.utilityworlds.com/Documentation/Categories Demonstrates how to use the Category Attribute to group input classes into specific categories within the Input Type dropdown. This is useful for organizing various input sources in an AI system. ```csharp [Category("Examples")] public class HealthInput : InputFromSource { } ``` -------------------------------- ### Delayed Entity Destruction in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v2 Allows for the destruction of entities after a specified delay. The `DestroyAfter()` method on EntityFacade provides a mechanism for scheduled entity removal. ```csharp public class EntityFacade { public void DestroyAfter(float delaySeconds) { // Implementation details } } ``` -------------------------------- ### Utility Entity Lifecycle Events - C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityWorld/UtilityEntity Provides an overview of the lifecycle event functions available in 'EntityFacade' for version 2.2.1 and later. These virtual methods (OnRegistered, OnActivated, OnEnabled, OnDisabled, OnDeactivated, OnUnregistered, OnDestroyed) can be overridden in custom entity facade classes to hook into various stages of an entity's existence within the utility system. ```csharp protected virtual void OnRegistered() { } protected virtual void OnActivated() { } protected virtual void OnEnabled() { } protected virtual void OnDisabled() { } protected virtual void OnDeactivated() { } protected virtual void OnUnregistered() { } protected virtual void OnDestroyed() { } ``` -------------------------------- ### Move Towards a Target Position Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Moves the agent towards a specified target position using Vector3.MoveTowards. Returns UpdateStatus.Success when the agent reaches the target, otherwise returns UpdateStatus.Running. ```C# public class MoveTowardsTarget : ActionTask { public class MoveTowardsTargetData { public Transform Target; public float Speed; } protected override UpdateStatus OnUpdate() { AgentController.transform.position = Vector3.MoveTowards(AgentController.transform.position, Data.Target.position, Data.Speed * Time.deltaTime); if (Vector3.Distance(AgentController.transform.position, Data.Target.position) < 0.1f) { return UpdateStatus.Success; } return UpdateStatus.Running; } } ``` -------------------------------- ### Update Blackboard GetVariable in C# Source: https://uintel-go.utilityworlds.com/Documentation/ReleaseNotes/v1 Demonstrates the updated usage of the `GetVariable()` function for the Blackboard in C#. This function now requires the variable type (`TVariable`) instead of the value type to retrieve Blackboard variables. This change was introduced in version 1.0.11. ```csharp public void TestBlackboard() { var blackboard = characterFacade.Entity.Intelligence.Blackboard; var sightRadiusVariable = blackboard.GetVariable("SightRadius"); sightRadiusVariable.Value = 30; } ``` -------------------------------- ### Create a Basic Wait Action Task in C# Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Defines a simple 'Wait' action task that inherits from 'ActionTask'. It measures elapsed time against a 'WaitTime' parameter to determine success or running status. Dependencies include the base 'ActionTask' class. ```csharp public class Wait : ActionTask { private float elapsedTime; public VariableReference WaitTime = 1.0f; protected override void OnStart() { elapsedTime = 0; } protected override UpdateStatus OnUpdate(float deltaTime) { elapsedTime += deltaTime; if (elapsedTime > WaitTime) return UpdateStatus.Success; return UpdateStatus.Running; } } ``` -------------------------------- ### Log Message to Console Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Logs a message to the console. This is a simple utility task for debugging or tracking agent actions. ```C# public class Log : ActionTask { public class LogData { public string Message; } protected override UpdateStatus OnUpdate() { Debug.Log(Data.Message); return UpdateStatus.Success; } } ``` -------------------------------- ### Group Fields in Intelligence Editor (C#) Source: https://uintel-go.utilityworlds.com/Documentation/Attributes Uses BoxGroup and FoldoutGroup attributes to visually organize class fields within the Intelligence Editor. Fields with the same BoxGroup name are placed in the same box, while FoldoutGroup creates collapsible sections. Supports various data types. ```csharp public class TestGroupTask : ActionTask { [BoxGroup("Group1")] public string Field1; [BoxGroup("Group1")] public int Field2; [BoxGroup("Group1")] public float Field3; [FoldoutGroup("Group2")] public string Field4; [FoldoutGroup("Group2")] public int Field5; [FoldoutGroup("Group2")] public float Field6; } ``` -------------------------------- ### Chase Target with NavMeshAgent Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Uses NavMeshAgent to chase a target. The target's position is updated every frame. Returns UpdateStatus.Success when the agent reaches the target, otherwise returns UpdateStatus.Running. ```C# public class ChaseTarget : ActionTask { public class ChaseTargetData { public Transform Target; } private NavMeshAgent navMeshAgent; protected override void OnStart() { navMeshAgent = AgentController.GetComponent(); } protected override UpdateStatus OnUpdate() { if (navMeshAgent != null && Data.Target != null) { navMeshAgent.SetDestination(Data.Target.position); if (!navMeshAgent.pathPending && navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance) { return UpdateStatus.Success; } } return UpdateStatus.Running; } } ``` -------------------------------- ### Rename Class Serialization Name (C#) Source: https://uintel-go.utilityworlds.com/Documentation/Attributes Allows renaming of class names during JSON serialization by specifying the old class name and optionally the old namespace. Useful for refactoring without breaking existing serialized data. Applies to classes inheriting from ActionTask. ```csharp namespace CarlosLab.NewNamespace { [ClassFormerlySerializedAs(oldClassName:"OldActionTask", oldNamespace:"CarlosLab.OldNamespace")] public class NewActionTask : ActionTask { } } ``` ```csharp namespace CarlosLab.Unchanged { [ClassFormerlySerializedAs(oldClassName:"OldActionTask")] public class NewActionTask : ActionTask { } } ``` -------------------------------- ### Face Target Source: https://uintel-go.utilityworlds.com/Documentation/UtilityIntelligence/ActionTasks Rotates the agent to face a specified target. Returns UpdateStatus.Success immediately after the first update. ```C# public class FaceTarget : ActionTask { public class FaceTargetData { public Transform Target; } protected override UpdateStatus OnUpdate() { if (Data.Target != null) { Vector3 direction = (Data.Target.position - AgentController.transform.position).normalized; if (direction != Vector3.zero) { Quaternion lookRotation = Quaternion.LookRotation(direction); AgentController.transform.rotation = lookRotation; } } return UpdateStatus.Success; } } ``` -------------------------------- ### Conditionally Show/Hide Fields (C#) Source: https://uintel-go.utilityworlds.com/Documentation/Attributes ShowIf and HideIf attributes control the visibility of fields in the Intelligence Editor based on the value of other fields. Supports conditions on boolean, enum, string, float, and int types. Useful for creating dynamic and user-friendly interfaces. ```csharp public class TestBoolTask : ActionTask { public bool Toggle; [ShowIf("Toggle")] public int ShowIfToggleDefault; [ShowIf("Toggle", true)] public float ShowIfToggleTrue; [ShowIf("Toggle", false)] public int ShowIfToggleFalse; [HideIf("Toggle")] public float HideIfToggleDefault; [HideIf("Toggle", true)] public float HideIfToggleTrue; [HideIf("Toggle", false)] public int HideIfToggleFalse; } ``` ```csharp public enum TestEnum { Type1, Type2, Type3, } public class TestEnumTask : ActionTask { public TestEnum Type; [ShowIf("Type")] public bool ShowIfTypeDefault; [ShowIf("Type", TestEnum.Type1)] public bool ShowIfType1; [ShowIf("Type", TestEnum.Type2)] public float ShowIfType2; [ShowIf("Type", TestEnum.Type3)] public int ShowIfType3; [HideIf("Type")] public bool HideIfTypeDefault; [HideIf("Type", TestEnum.Type1)] public bool HideIfType1; [HideIf("Type", TestEnum.Type2)] public float HideIfType2; [HideIf("Type", TestEnum.Type3)] public int HideIfType3; } ```