I managed to implement a basic AI script to follow a target around.
But for some reason the movement is bouncy. Basically what’s happening is when the path is recalculated, the capsule I’m moving using the code below is going to the first waypoint in the next path, which seems to be the previous waypoint in the current path. This happens with and without the funnelmodifier. The code is below:
Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized;
dir *= speed;
transform.position = Vector3.MoveTowards(transform.position, dir+transform.position, speed);
I actually managed to fix it by changing the OnPathComplete to reset the currentWaypoint counter to 1 instead of 0, but I’m wondering if this is a correct solution, and as to why this is happening in the first place?