Contents

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:

    True if the path’s end point should connect to its start point; otherwise False.

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 init(toStayOn:maxPredictionTime:) or init(toFollow:maxPredictionTime:forward:) method.

For more information, see GameplayKit Programming Guide.

See Also

Creating a Path