     return false;
 }
 
+void followPath(float timeStep)
+{
+    if (startPosDefined && endPosDefined)
+    {
+        // Get next waypoint to reach
+        NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
+		currentPath = navMesh.FindPath(Jack.position, endPos);
+		if (currentPath.length < 2)
+		    return;
+		Vector3 nextWaypoint = currentPath[1]; // NB: currentPath[0] is the starting position
+        if (Floor(Jack.position.x) ==  Floor(endPos.x) && Floor(Jack.position.z) ==  Floor(endPos.z))
+            return;
+
+        // Rotate Jack toward next waypoint to reach and move
+        Jack.LookAt(nextWaypoint, Vector3(0.0f, 1.0f, 0.0f));
+        Jack.TranslateRelative(Vector3(0.0f, 0.0f, 1.0f) * 5 * timeStep);
+    }
+}
+
 void HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     // Take the frame time step, which is stored as a float

        // Rebuild part of the navigation mesh, then recalculate path if applicable
        NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
        navMesh.Build(updateBox);
        RecalculatePath();
    }
}


//     - Performing path queries to the navigation mesh
//     - Rebuilding the navigation mesh partially when adding or removing objects
//     - Visualizing custom debug geometry
//     - Raycasting drawable components
//     - Make a node follow the Detour path

#include "Scripts/Utilities/Sample.as"

