Recast Graph + Explosion Knockback

Hi Everyone,
I’m almost certainly going about this the wrong way, but I can’t seem to find any documentation on how to do what I want to do.

Essentially, I’m trying to have an enemy that gets thrown backwards away from the explosion, and then resumes walking toward the target from wherever they land.

My setup is RichAI + RVOController (as an aside, I’m also using FinalIK);

If I leave RichAI + RVOController enabled then the explosion won’t force them backwards (though it does seem to allow them to fly straight upwards).

If I then disable the scripts while the explosion takes effect, I get a weird teleport and wobble after I re-enable them (The wobble may have something to do with FinalIK).

I’ve played around with trying to clear the target, and even playing with the Init code that looks for Nodes nearby.

I am incredibly new to A*, so there is a pretty good chance I’m just doing something stupid.



Note also, that I have now installed 4.1 beta and it still exhibits the same behaviour


The RichAI script wants to keep track of where it is in the graph at all times and if it gets lost it will have to move to the closest node it knows about. I’m not quite sure, but this might be the cause of the wobble when you re-enable the RichAI script. Or it might have nothing at all to do with it.

Anyway. I think the best way to do this is to use the new Move method on the RichAI that was added in 4.1. Call it using whatever additional movement you want the agent to do each frame and it will perform it and still properly clamp it to the navmesh without any additional jitter that can happen if you do it in other ways.

I would do it something like this (I haven’t tested it though):

IEnumerator Explosion (IAstarAI ai) {
    // Optionally make the AI stop trying to move while being pushed
    ai.isStopped = true;
    for (float t = 0; t < 4; t += Time.deltaTime) {
        ai.Move(Vector3.right * Time.deltaTime * 1 / (t + 0.1f));
        yield return null;
    // Optional
    ai.isStopped = false;
1 Like

Sorry for picking this up again, but your solution for this works perfectly. Iam also using this right now.