Question: RichAI to specific Graph

Hello, there is a way for “RichAI” to be in a certain “Graph”?
Thank you for your attention.

Hola, hay forma de que “RichAI” este en un determinado “Gráfico”?
Gracias por la atencion prestada.


Yes it is possible.
It is not possible out of the box with the current movement scripts, but it is a very easy fix.
You do it by passing the graphMask parameter to the seeker.StartPath method.
This is a bitmask, see

1 Like

Could you give me an example?

Buenas tardes.
Tengo este código hecho y me gustaría agregarle soporte a GraphMask.
La duda seria como agregar este soporte y que permita calcular constantemente la ruta.
hay alguna forma directa de definir en cual GraphMask está trabajando?
Gracias por la atención prestada.

Good afternoon.
I have this code done and I would like to add support to GraphMask.
The doubt would be how to add this support and allow to calculate the route constantly.
Is there any direct way to define which GraphMask is working on?
Thank you for your attention.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pathfinding;

public class CharacterBotAI : AIPath
    public GeneratePoints generatePoints;
    public Transform targetPosition;
    public bool isFinishDistance = false;
    public float distance = 2;

    public Animator animator;
    public float sleepVelocity = 0.4F;
    public float animationSpeed = 0.2F;

    private IAstarAI ai;

    new void OnEnable()
        ai = GetComponent<IAstarAI>();
        if (ai != null) ai.onSearchPath += Update;

    new void OnDisable()
        if (ai != null) ai.onSearchPath -= Update;

    public new void Start()
        targetPosition = generatePoints.ListGameObject[Random.Range(0, generatePoints.ListGameObject.Count)].transform;

    public override void OnTargetReached()
        if (!isFinishDistance && targetPosition != null && Vector3.Distance(tr.position, targetPosition.transform.position) > endReachedDistance / 2)
            targetPosition = generatePoints.ListGameObject[Random.Range(0, generatePoints.ListGameObject.Count)].transform;
            Debug.Log("Llego " +;

    protected override void Update()

        if (targetPosition != null) ai.destination = targetPosition.position;

        if (isFinishDistance && targetPosition != null && Vector3.Distance(this.transform.position, targetPosition.transform.position) < distance)
            targetPosition = generatePoints.ListGameObject[Random.Range(0, generatePoints.ListGameObject.Count)].transform;

        Vector3 relVelocity = tr.InverseTransformDirection(velocity);
        relVelocity.y = 0;

        if (relVelocity.sqrMagnitude <= sleepVelocity * sleepVelocity)
            animator.SetFloat("Blend", 0);
            animator.speed = 1;
            animator.SetFloat("Blend", 1);

            float speed = relVelocity.z;
            animator.speed = speed * animationSpeed;



For this you can override the SearchPath method:

/** \copydoc Pathfinding::IAstarAI::SearchPath */
public override void SearchPath () {
	if (float.IsPositiveInfinity(destination.x)) return;
	if (onSearchPath != null) onSearchPath();

	lastRepath = Time.time;
	waitingForPathCalculation = true;


	Vector3 start, end;
	CalculatePathRequestEndpoints(out start, out end);

	// This is where we should search to
	// Request a path to be calculated from our current position to the destination
	int graphMask = 1 << 2; // Or something
	seeker.StartPath(start, end, null, graphMask);

Muchas gracias por la pronta respuesta aron
Solucionaste mi problema.