Skip to main content

Follow Path Spline

Makes the entity follow a given spline path. The path is set up as SplineContainer. A scene using this behavior must have a single instance of FollowPathSplineManager, which holds references SplineContainer. The spline to use is selected using the FollowPathSplineIndex. For a sample that uses this behavior, see 2D Movement Sample scene.

FollowPathSplineJob

The behavior affects both direction and the speed. This behavior is unusual from the others, because it uses an additional system, the FollowPathSplineSystem. The system updates FollowPathSplineComponent.Dir, which is a direction either along the curve, or perpendicularly towards the curve if the entity is too far from it. The behavior then returns FollowPathSplineComponent.Dir at constant speed with constant desire.

This behavior outputs the following:

  • DesiredDirection - Direction FollowPathSplineComponent.Dir, along the curve or towards it.
  • DirectionDesire - DirectionStrength (constant)
  • DesiredSpeed - Speed (constant)
  • SpeedDesire - SpeedStrength (constant)
  • Priority - Priority (constant)

FollowPathComponent

The main interesting properties to adjust on FollowPathComponent are:

  • Speed - How fast the entity should travel.
  • DistanceThreshold - Threshold distance to curve, where the entity moves purely along the curve.
  • DistanceThresholdWidth - At distance DistanceThreshold + DistanceThresholdWidth to curve, the entity moves purely towards the curve.
  • Power - Power for blending between direction along and towards the curve as distance increases.
  • Loops - Should the entity loop around the path.
  • LookAhead - How far ahead should the entity look when looking for a nearest point on the curve.
  • BaseData
    • DirectionStrength - Determines DirectionDesire.
    • Priority - Priority.

FollowPathSplineIndex

This component holds index into the array of splines in FollowPathSplineManager. The entity will use the path under the specified index. The index can be set in the FollowPathSplineAuthoring.