Instance Method

initWithPoints:count:radius:cyclical:

Initializes a path with the specified array of 2D points.

Declaration

- (instancetype)initWithPoints:(vector_float2 *)points count:(size_t)count radius:(float)radius cyclical:(BOOL)cyclical;

Parameters

points

An array of 2D points representing the vertices in the path. The order of points in this array determines the order in which an agent follows the path.

count

The number of elements in the pointsarray.

radius

The radius of the path.

cyclical

YES if the path’s end point should connect to its start point; otherwise NO.

Return Value

A new path object.

Discussion

The radius parameter defines the space occupied by the path—think of this space as the area created by sweeping a circle of the specified radius along the path from vertex to vertex. Agents with path-related goals will attempt to move to or stay within this area.

The cyclical parameter determines whether the path loops around on itself. If the path is cyclical, an agent with a follow-path goal will proceed around the path indefinitely. If the path is not cyclical, an agent following the path will stop at the last point in the path.

To use the newly created path to constrain an agent’s behavior, create a goal with the goalToStayOnPath:maxPredictionTime: or goalToFollowPath:maxPredictionTime:forward: method.

See Also

Creating a Path

pathWithPoints:count:radius:cyclical:

Creates a path with the specified array of 2D points.

initWithFloat3Points:count:radius:cyclical:

Initializes a path with the specified array of 3D points.

pathWithFloat3Points:count:radius:cyclical:

Creates a path with the specified array of 3D points.

initWithGraphNodes:radius:

Initializes a path using the positions of the specified graph nodes.

pathWithGraphNodes:radius:

Creates a path using the positions of the specified graph nodes.