Keeping AI Bot movement constrained to a path

Hi - I want a spawned AI Bot to run from point A to Point B. I have this working via a “Simple Move To Location” node and specifying the vector of the final area I want the Bot to run to.
I’ve also prevented the Bot running diagonally from A-B by creating a maze like series of Nav Mesh Bounds Volumes.

While this works I’m wondering if there is a more efficient workflow for a larger environment ?
The Bot will be running along a curved road and I want the Bot to stay in the center of the road (more or less).
Is there any way of drawing or importing a spline and constraining the Bots movement along the spline ?

While not nearly an expert on this subject, the first thing that comes to my mind is to place an array of target points along your path and use the moveto to go from one to the other.

Just a thought. Hopefully someone with more experience with this comes along after me and has a better solution for you. :slight_smile: Have a great day!

I created a waypoint system which uses the nav mesh to go from one waypoint to the next waypoint. Once a character reaches a waypoint, he performs any specific action at that waypoint position and then resumes onto the next waypoint. This lets me create arbitrary paths which any actor can follow.

I wrote my system in C++ and I’m willing to share my header file code:

enum class EWaypointMethod : uint8
	//We are moving directly to the next waypoint.

	//We are wandering towards the waypoint

	//we are moving to the next waypoint but we may interrupt our travels to do something more important, such as attacking an enemy.

/*Creatures may use different actions when*/
enum class EActionType : uint8
	//the creature is not doing anything

	//The creature is going through a spawning sequence

	//the creature is doing a melee attack

	//the creature is doing a grab attack

	//the creature is doing a smash attack

	//creature is performing a ranged attack

	//creature is doing a special attack type 1

	//creature is doing a special attack type 2

	//creature is doing a special attack type 3

	//creature is taking damage

	//creature is performing its celebration activity, whatever that is.

	//the creature is searching around the area

	//the creature is teleporting out

	//the creature is teleporting in

class AWaypoint : public AActor

	//The world position of the waypoint
	//UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint", meta = (MakeEditWidget))
	//FVector Position;

	//how close a character has to get to the waypoint for it to be considered "reached"
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
	float AcceptanceRadius = 50;

	//might want to add an arrow component so that we can see the waypoint in the editor
	USceneComponent* Root;

	UArrowComponent* Arrow;

	USphereComponent* Area;

	UTextRenderComponent* Label;

	/*The character moving to this waypoint will run at full speed if this is checked.*/
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
	bool bShouldRun = false;

	/*If you want your character to perform a particular action when they arrive at this waypoint, you can set that here.*/
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
	EActionType OnArriveAction = EActionType::None;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
	bool RefreshPath = false;

	/*After reaching this waypoint, a character will go to the next waypoint.*/
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
	AWaypoint* NextWaypoint;

	AWaypoint(const FObjectInitializer& ObjectInitializer);

	UFUNCTION(BlueprintCallable, Category = "Waypoint")
		float GetAcceptanceRadius() const;

		virtual void OnConstruction(const FTransform& inTransform) override;

	/*This gets the location of the waypoint*/
	UFUNCTION(BlueprintCallable, Category = "Waypoint")
		FVector GetLocation() const;

	/*Note: If the player is being guided to a waypoint, we may want to draw some sort of in-game path by moving some sort of visual effect
	along the waypoint nav path*/

	This gives you the navigation path necessary to get to the current waypoint / objective.
	@param ForActor This is a reference to the actor which we're generating the path for.
	@param StepSize This is how many increments we have between our vectors
	@param NavHeight This is the ray delta height we use to follow contours of navigable terrain. Use smaller values indoors!
	UFUNCTION(BlueprintCallable, Category = "Waypoint")
	TArray<FVector> GetNavPath(AActor* ForActor, float StepSize = 100, float NavHeight = 500) const;

class AWaypointList : public AActor


	AWaypointList(const FObjectInitializer& ObjectInitializer);

	UPROPERTY(VisibleAnywhere, Category = "Default")
	USceneComponent* Root;

	UPROPERTY(VisibleAnywhere, Category = "Default")
		UBillboardComponent* Billboard;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Default", meta = (MakeEditWidget))
		TArray<AWaypoint*> WaypointList;

	UPROPERTY(EditAnywhere, Category = "Default")
	bool bShowDebugInfo = false;

	virtual void OnConstruction(const FTransform& inTransform) override;

	/*Note: I think the waypoints we insert are going to be relatively positioned to this list, so I should verify the positioning.*/


I do it in my tower defence game using a spline.

I set my waypoints using a blueprint that has an array for my custom waypoints on there. I then get the location of them and add them into a spline array and generate the spline.