• Articles
  • Api Documentation
Show / Hide Table of Contents
  • Introduction to AlchemyNavigation
  • Main components
    • Alchemy Navigation System
    • Faces Holder
    • Simple Agent
    • Movement Modifier
  • Building a surface
    • How it works
    • Bake from geometry
    • Debugging holders

Simple Agent

The SimpleAgent is a component that allows you to create characters that intelligently move along navigation meshes to their destinations.

To begin attach the SimpleAgent component to the game object.

Inspector Property Description
Layer Defines which layer the agent belong to.
Area Mask Specifies on which areas the agent can move.
Radius Defines how close the agent center can get to edges of the navigation mesh.
Stopping Distance The minimum distance to the target point to stop the movement.
Max Velocity The maximum velocity magnitude. (How fast the agent can move.)
Max Acceleration The maximum acceleration magnitude. (How fast the agent can gain speed.)
Rotation Speed How fast the agent can rotate.
Draw Gizmos If true, gizmos is drawn.

Implementation example

As an example, consider a behavior where the agent is patrolling between two points. The code could look like this:

using AlchemyBow.Navigation.Simple;
using UnityEngine;

public class PatrolBehaviourExample : MonoBehaviour
{
    [SerializeField]
    private Vector3 checkpointA = Vector3.zero;
    [SerializeField]
    private Vector3 checkpointB = Vector3.zero;

    [SerializeField]
    private SimpleAgent agent = null;

    private bool direction;

    private void OnEnable()
    {
        agent.OnDestinationReached += OnCheckpoint;
        OnCheckpoint();
    }

    private void OnDisable()
    {
        agent.OnDestinationReached -= OnCheckpoint;
        agent.CancelAllRequests();
    }

    private void OnCheckpoint()
    {
        direction = !direction;
        agent.SetDestination(direction ? checkpointA : checkpointB, false);
    }
}

You should know

  • The SimpleAgent does not provide avoidance behaviour it self. It is done with the help of movement modifiers.
  • You can create custom agents - see BasicAgent. However, in most cases the SimpleAgent is what you are looking for.
  • Improve this Doc
In This Article
Back to top Generated by DocFX