I have an 8 way direction top-down 2D isometric game based on X,Y axis.
I made a NPC character which has AI Lerp, RVO Controller and Seeker components on it.
Also NPC has NPCFollow script attached on it which I wrote it before. It basically does handles of follows the target and handles the animations. You can check this in here. But actually this doesn't work correctly. https://paste.ofcode.org/fa3pR23izv3TZ7mvYv83s8
If there is more optimized or good solution for this I would like to hear that.
So, what is my problem? The problem is I called FollowTarget function every 0.3 seconds. In line of 71th as you can see there is an callback function for OnPathComplete. While this is working it calculates the direction of the character. But this is happens every 0.3 seconds. So what its that mean? If NPC character reaches the closest point of path before than 0.3 seconds that the animations being late for new transation because path didn't update yet. So are there any function that did I reache the closest node? Function like OnTargetReached () in AILerp?
Also I want to share my animation system on Unity.
As you can see on below pictures, I have 8 different animation types which they have some parameters. Parameters depends on SpeedX and SpeedY values which they are actually based on between -1 and 1 values. If I get the nearest node position or something that gives me to direction on Path, than I can set animation variables like in 32th - 33th line of codes.
Also you can see the problem in video here: