Trigger script at each path location
« on: February 24, 2016, 04:27:23 PM »
Is there a way to tell which point on the path the tween is currently at? I'd like to be able to trigger functions at each point of the path.

This would be an excellent update to be able to specify a script to run as the object reaches each point on the path.




Re: Trigger script at each path location
« Reply #1 on: February 24, 2016, 07:56:56 PM »
You're probably looking for the "OnWaypointChange" callback.  Here's an example, straight from the docs...

Code: [Select]
void Start() {
   transform.DOPath(waypoints, 1).OnWaypointChange(MyCallback);
}
void MyCallback(int waypointIndex) {
   Debug.Log("Waypoint index changed to " + waypointIndex);
}