Skip to main content

Splines

Paths can generate Splines for use in navigation, AI, camera systems, or to guide Dependent Paths. Splines in the PathTemplate should derive from EpSplineComponent (Base Spline) as this class allows for controlling whether a spline should automatically merge with another spline when their endpoints are close to each other.

info

Splines are spawned in the SplineSubActor separately from other components (see documentation)

The video below demonstrates process of adding and spawning BaseSplines.


Visibility

Visibility of spawned splines is controlled by the "Splines" button in the Errant Paths Mode and their "Visibility" property.

image image

Available options:

  • Always Visible - will show spawned splines of a selected SubActor even if the button is not toggled.
  • Always Hidden - will never show spawned splines of a selected SubActor.
  • Visible in Splines Visualization - will show spawned splines of a selected SubActor only if the button is toggled.
info

SubActors need to be selected to make the splines visible

CanMergeWith Function

When splines of same class are in proximity Errant Paths will try to merge them. When the ends of one spline are close to the ends of another spline (within one Path, splines of the same class), Errant Paths will try to merge them into a single spline. The distance threshold is based on "Max Dist Between Ends to Merge Splines" setting from a PathDescription.

image

However, merging two splines together may be undesirable if the splines have certain properties set to different values (ex: color, type, tags, etc.). To prevent merging, you can override CanMergeWith function, both in Blueprint and in C++.

Blueprint

To override CanMergeWith in blueprint, your class needs to inherit EpSplineComponent (Base Spline)

image

To override function in a Blueprint:

  • Open your Custom Spline Blueprint.
  • In Functions section of your Blueprint override CanMergeWith function image

CanMergeWith Function has an input parameter Other Spline, which refers to another EpSplineComponent instance, which is being considered for merging with this instance. You can use it to decide if you allow splines to merge, for example by casting it to your custom spline type, reading a variable, and comparing its value with the same variable from this instance.

note

In this example CanMergeWith function override, tries casting spline to our custom class, if it succeeds it gets compared against this instance's CustomType value. CustomType is a variable we added for this specific customization.

C++

To override CanMergeWith in C++, your class needs to inherit UEpSplineComponent

class UCustomSplineExample : public UEpSplineComponent
{
virtual UEpSplineComponent* CanMergeWith(UEpSplineComponent& OtherSpline, float MaxDistBetweenEnds) override;
}
ParameterDescription
OtherSplinePointer to another spline instance that is being considered for merging with the current instance.
MaxDistBetweenEndsSetting taken from PathDescription, defaults to 20 cm.
ReturnsDescription
UEpSplineComponent*Pointer to a spline that will be treated as the primary spline i.e. to which the secondary spline will be merged to. This decides the connection order - you typically want to pick the primary spline so that it ends where the secondary spline starts.

Return nullptr if splines shouldn't be merged.
info

The base implementation of CanMergeWith handles testing the distance and deciding the order of the connection and calls the CanMergeWith Blueprint event if the spline ends are close to each other.

Example class that overrides CanMergeWith():

UCLASS(Blueprintable)  
class UCustomSplineExample : public UEpSplineComponent
{
GENERATED_BODY()
public:

virtual UEpSplineComponent* CanMergeWith(UEpSplineComponent& OtherSpline, float MaxDistBetweenEnds) override
{
return bMerge ? Super::CanMergeWith(OtherSpline, MaxDistBetweenEnds) : nullptr;
}

UPROPERTY(EditAnywhere)
bool bMerge = false;
};