How to properly feed RichAI a Flee path or other path type

I have the RichAI and RVOController attached to my enemy character and it goes after the player while avoiding other enemies accordingly. I want the enemy to run away once sufficiently damaged so I figured the best way to do that was to feed a Flee path to RichAI but would also like to be able to feed other path types to it as well.

So, I did some testing and while I was able to get the enemy to flee, it would then bounce back and forth between the flee destination and I guess where it was when it started fleeing and never updated the path… plus there were some errors so I scrapped that test and figured I would post here for help :slight_smile:

What I want to do is be able to feed the RichAI script any type of path and have it switch using and updating that path type until fed a different type of path. I imagine that is rather simple and I just don’t know what I am doing :confused:

Thanks.

So, I can feed it a RandomPath without issue, but if I feed it a FleePath, it complains about pooling.

So if in UpdatePath() and SearchPaths() I replace:
seeker.StartPath(tr.position, target.position);

With:

`_randomPath = new RandomPath();
_randomPath = RandomPath.Construct(transform.position, 10000);
_randomPath.spread = 10000;
seeker.StartPath(_randomPath);`

It works fine. But if instead I replaced RandomPath in the above code with FleePath, I get the following Errors:

  1. ArgumentException: Cannot recycle path of type ‘FleePath’ in a pool for path type ‘RandomPath’. Most likely the path type does not have support for recycling. Please do not call Recycle() on that path

  2. ArgumentException: You are releasing a path which is not claimed at all (most likely it has been pooled already). Are you releasing the path with the same object (object name (Seeker)) twice?

So, I didn’t create the pool, whatever pool it is talking about is not created by my code.

Suggestions?

Hi

1) ArgumentException: Cannot recycle path of type 'FleePath' in a pool for path type 'RandomPath'. Most likely the path type does not have support for recycling. Please do not call Recycle() on that path
That seems to be a bug. I have forgot to add support for pooling to the FleePath.

You can solve it by adding the function
protected override void Recycle () { PathPool<FleePath>.Recycle (this); }
To the FleePath.cs script

Thanks, that takes care of it. Noticed some issues with the Funnel Simplification as well but I will make a new thread for that.