# Movement along the polyline

We continue supporting the functions that make agents move along specified polylines. However, they are left more for compatibility with AnyLogic 6. We recommend you to use paths and make agents move along paths in the networks instead of using old-fashioned and non-manageable polylines. However, there is at least one case when you may need these functions. Assume you have a model with a huge network, and want some agent to move along the specified path. In network, agents always move along the shortest route. So it will be impossible to make your agent move along some path that is not on the shortest route. In this case you can draw a polyline and make agent move along this polyline using one of the following functions.

#### The common rules for all functions:

• If the agent is currently not on the path, it will first move to the closest point on the path.
• If the target is not on the path, the agent will move along the path to the point closest to the target, and then move to the target.
moveTo() - Movement
 Function Description void moveTo( double x, double y, ShapePolyline path) Starts agent movement to the destination along a given polyline. The destination is specified using X, Y coordinates. Z coordinate of target (and polyline points) is the same as the current agent's Z coordinate.  Parameters: x, y :  X-, Y- coordinates of the target location path - the polyline along which the agent will move void moveTo(double x, double y, double z,  ShapePolyline path) Starts agent movement to the destination along a given polyline. The destination is specified using X, Y, Z coordinates. Parameters: x, y, z :  X-, Y-, Z- coordinates of the target location path - the polyline along which the agent will move void moveTo(Point location,  ShapePolyline path) Starts agent movement to the destination along a given polyline. The destination is specified as Point object. Parameters: location - the target location path - the polyline along which the agent will move
moveToInTime() - Movement that takes the specified time
All these functions start movement of the agent to the specified destination along the given path in continuous 3D space.

The movement time is defined by the function arguments, so the agent speed depends on the specified trip time and the distance to the destination.

 Function Description void moveToInTime( double x, double y,  ShapePolyline path, double tripTime) Starts agent movement to the destination along a given polyline. Movement will take the given trip time, specified in model time units. The destination is specified using X, Y coordinates. Z coordinate of target (and polyline points) is the same as the current agent's Z coordinate.  Parameters: x, y :  X-, Y-  coordinates of the target location path - the polyline along which the agent will move tripTime - the time of the movement trip, in model time units void moveToInTime( double x, double y, ShapePolyline path, double tripTime, TimeUnits units) Starts agent movement to the destination along a given polyline. Movement will take the given trip time, specified in given time units. The destination is specified using X, Y coordinates. Z coordinate of target (and polyline points) is the same as the current agent's Z coordinate.  Parameters: x, y :  X-, Y-  coordinates of the target location path - the polyline along which the agent will move tripTime - the time of the movement trip, in time units defined by the next argument units - time unit constant void moveToInTime(double x, double y, double z,  ShapePolyline path, double tripTime) Starts agent movement to the destination along a given polyline.  Movement will take the given trip time, specified in model time units. The destination is specified using X, Y, Z coordinates. Parameters: x, y, z :  X-, Y-, Z- coordinates of the target location path - the polyline along which the agent will move tripTime - the time of the movement trip, in model time units void moveToInTime(double x, double y, double z,  ShapePolyline path, double tripTime, TimeUnits units) Starts agent movement to the destination along a given polyline.  Movement will take the given trip time, specified in given time units. The destination is specified using X, Y, Z coordinates. Parameters: x, y, z :  X-, Y-, Z- coordinates of the target location path - the polyline along which the agent will move tripTime - the time of the movement trip, in time units defined by the next argument units - time unit constant void moveToInTime( Point location,  ShapePolyline path, double tripTime) Starts agent movement to the destination specified as Point object along a given polyline. Movement will take the given trip time, specified in model time units. The destination is specified as Point object. Parameters: location - the target location path - the polyline along which the agent will move tripTime - the time of the movement trip, in model time units void moveToInTime( Point location,  ShapePolyline path, double tripTime, TimeUnits units) Starts agent movement to the destination along a given polyline.  Movement will take the given trip time, specified in given time units. The destination is specified as Point object. Parameters: location - the target location path - the polyline along which the agent will move tripTime - the time of the movement trip, in time units defined by the next argument units - time unit constant