Hello,
I wrote a class that extends AIPath to allow for easily creating patrol routes. Basically the child class has an array of ordered Transforms that the class will target, in order, one at a time to cause the character to follow a given patrol route. The child class just simplifies doing things like setting the patrol route to Loop or PingPong via the inspector. The problem I have run into is when I want the character to smoothly move from target to target (i.e., waypoint to waypoint).
The way I have it setup right now is that I overloaded the OnTargetReached() method. When that is called I know my character has reached a waypoint. I then increment the waypoint counter and set the target to the next waypoint transform. This works great but the character stops after reaching each waypoint before moving to the next. Sometimes this is the desired behavior but I also want to be able to enable smooth movement between waypoints.
I thought I could do this by setting the “End Reached Distance” to cause the OnTargetReached() method to trigger a little earlier and thus set the target to the next waypoint before the character stops moving but it turns out (after reading the documentation) that once “End Reached Distance” is reached, all movement stops (even if you’re short of the target position). As a result, this doesn’t really work.
Is there a way using the base AIPath class to get the desired behavior? Basically I need a version of OnTargetReached() that triggers once the character is within a certain distance of the target. Is there a simple way to test for something like this that is fairly performant? Thank you!
~Sarus