A* Pathfinding Project

Recast Graph for small rooms?



I have a lot of scenes in my game, one has a huge terrain where I am using a Recast graph and RichAi, but now I started working on smaller scenes for each house interior, I am wondering if it is still a good idea to use Recast graph and RichAi because I want to have the same NPCs walking there and I want to use the same code.



Are the interiors connected to the rest of the graph in any way? Or are they completely separate (with some teleportation logic or something)?


No they are a completely separate scene (each house like in Skyrim)


Using one separate graph (or multiple separate graphs) for the interiors should work well I think. Is there any reason you feel like it might not work well?


But can you use the same AI code for different type of graphs? I have only used Recast so I dont know if my code will work on other graphs.


The RichAI movement script only works for navmesh/recast graphs, the AIPath movement script works for all graph types.
All movement scripts implement the IAstarAI interface however, so even if you use another movement script, the API is likely very similar.

Without knowing more about your code it’s hard for me to say if it will work on other graph types.


For now Im only using this

    private IAstarAI _aStarAi;

    public void OnAnimatorMove()
        if (Time.deltaTime <= 0 || !Context.UpdateMovement) return;

        Vector3 nextPosition;
        Quaternion nextRotation;

        _aStarAi.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);

       _aStarAi.FinalizeMovement(new Vector3(Context.Animator.rootPosition.x, nextRotation.y, Context.Animator.rootPosition.z), nextRotation);

    public IAiContext Context { get; set; }



Okay. Since you are using the IAstarAI interface, that should work equally well with the AIPath movement script. The movement may be slightly different though as AIPath and RichAI work differently.