A* Pathfinding Project

How to make agents avoid player?


#1

How can I get agents to avoid the player?
I tried using a Navmesh Cut that moves with the player and it works if the agents are passing by the player, but not if they are specifically targeting the player. (The agents will have a hard time going to the player)
Is there another way of doing that? Or maybe have Navmesh Cut only work for some specific agents?
Preferably a way without using RVO, because it’s causing few issues in my game.


#2

Hey,

From a previous similar post:


#3

Thank you for the quick answer.
I have a question about the interface:
I am following the circuit board example, how do I get the node that the player is on, so I can block it?

I am using the Recast graph.

This is the code I am using:

                                Blocker traversalProvider = new Blocker();
                                ABPath path = ABPath.Construct(transform.position, attackTarget.position);
                                path.traversalProvider = traversalProvider;
                                AstarPath.StartPath(path, true);
                                path.BlockUntilCalculated();
                                seeker.PostProcess(path);
                                //traversalProvider.blockedNodes.Add(node);
                                richAi.SetPath(path);

#4

To be honest I’m not actually sure if the this will work great on recast graphs.

Here is how you can get the closest node to the player:
AstarPath.active.GetNearest(Player.Position, NNConstraint.Default)


#5

The interface didn’t work with Recast, but I was able to make it work with RVO, thank you.