A*Star Pathfinding Issue (Video and Code Included)

Notes: I am using Kinematic Character Controller to handle the movement via the steering agent.
Code:using System.Collections;using System.Collections.Generic;using UnityEngine; - Pastebin.com
Video:A*Star shimmying issue - YouTube

What should be happening. There are currently two states which handles pathfinding: Chase and Search.
When the AI has vision of the player it moves to the player while updating the current path. Once it loses vision of the player it enters search mode which basically moves toward the last seen position of where the player was.

What is happening. As soon as it loses vision of the player it seems stops committing to the current path and creates a new path which is very inefficient to the previous. It should commit to the last seen position of the player. What I’m confused about is why it would create this new path because it would take more time to get to the player’s last seen position.

I have tried using the RichAI component to move the character, it doesn’t handle states but it kind of does the same thing. If you shimmy back and forth when the player is on the opposite side of the wall. The AI gets confused, rather than committing to it’s path it keeps recalculating.

Video using RichAI Movement Shimmying issue 2 - YouTube


Some inefficient pathingInefficient Pathing - YouTube
I want to note that I am using RichAi.SearchPath() and RichAi.destination = Vector3 to update the pathfinding since I dont want it to do this for non chasing states.