# Character stopping before moving to next waypoint

**URL:** <https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417>\
**Category:** AI\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [February 19, 2015, 9:38am UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417 "2015-02-19T09:38:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harminder\_Singh\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Harminder\_Singh\_1](https://forums.unrealengine.com/u/Harminder_Singh_1)\
**Post date:** [February 19, 2015, 9:38am UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/1 "2015-02-19T09:38:18Z")

</div>

Hi There,

I followed this [AI tutorial series][1] to create a target point based path for my AI character. Everything is working as expected, but there is a small delay with my character when it moves to a new target point. It looks like the character stops and rotates and then continues to the next target point.

Is there a way to make it so that the character does not stop when rotating/going to next target point?

blueprints:

Character blue print:

 ![30444-character+blueprint.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/1/0f15f6d443d31765e6f69c51fe86b0235b5b0188.jpeg)

Behavior tree

 ![30445-btree.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/3/3b3eda07b5ed1fd621d18f6ad0b290e44bb27bef.jpeg)

Target point/way point.

 ![30446-waypoint.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/5/d4538d6c1a59831eeb2a337ecb87707ac452b252.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 21, 2016, 2:08pm UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/2 "2016-04-21T14:08:34Z")

</div>

Hi ! Have you find a solution ? I have the same question 🙂

---

<div class="post-metadata">

**Author:** ![Jorjouto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jorjouto](https://forums.unrealengine.com/u/Jorjouto)\
**Post date:** [February 1, 2017, 6:20pm UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/3 "2017-02-01T18:20:23Z")

</div>

I have the same question too! Any solutions?

---

<div class="post-metadata">

**Author:** ![Jorjouto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jorjouto](https://forums.unrealengine.com/u/Jorjouto)\
**Post date:** [May 3, 2017, 5:04pm UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/4 "2017-05-03T17:04:58Z")

</div>

Hey Buddy! I found the solution to this. The character stops on each waypoint because it takes time for the moveto task to finish execute and then set the next waypoint on the btt and then continue. This simply is too slow. The update of where the character will move to next must be recalculated at frame speed so the change becomes seemless. This means it must be handled in the tick task.

The approach I took was making a custom task called patrol, which will check each frame if the character has reached the next waypoint and if so, (without aborting), setting and calling moveto to the next waypoint after that.

Take a look at the btt picture and the code. It will make it easier to understand 🙂

void UBTT\_Patrol::TickTask(UBehaviorTreeComponent& OwnerComp, uint8\* NodeMemory, float DeltaSeconds)  
{  
Super::TickTask(OwnerComp, NodeMemory, DeltaSeconds);

```
AWaypoint* nextWaypoint = character->GetNextWaypoint();
currentWP = nextWaypoint;

// If there is next waypoint then try moving to it
if (currentWP != nullptr)
{
	FVector currentWPLocation = currentWP->GetActorLocation(); FVector characterLocation = character->GetActorLocation(); currentWPLocation.Z = characterLocation.Z;	// to avoid problems with WP and character height difference

	// If character already arrived to target
	if (currentWPLocation.Equals(characterLocation, 60.0f))
	{
		bMoving = false;

		// Check if target changed
		if (currentWP != nextWaypoint)
		{
			currentWP = nextWaypoint;
	else
	{
		if (bMoving)
		{
			if (currentWP == nextWaypoint)
			{
				bMoving = false;
			}
			else
			{
				// If target changed try moving to it
				currentWP = nextWaypoint;
				ownerController->MoveToActor(currentWP, AcceptableRadius, bStopOnOverlap);
			}
		}
		else
		{
			// If not moving move to the waypoint
			ownerController->MoveToActor(currentWP, AcceptableRadius, bStopOnOverlap);
			bMoving = true;
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![Jorjouto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jorjouto](https://forums.unrealengine.com/u/Jorjouto)\
**Post date:** [May 3, 2017, 5:06pm UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/5 "2017-05-03T17:06:19Z")

</div>

Hey buddy check out my answer for this if youre still stuck!

---

<div class="post-metadata">

**Author:** ![Jorjouto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jorjouto](https://forums.unrealengine.com/u/Jorjouto)\
**Post date:** [May 3, 2017, 5:08pm UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/6 "2017-05-03T17:08:21Z")

</div>

(LOOK AT MY COMMENT ABOVE FOR PROPPER CODE FORMATTING!)

Hey Buddy! I found the solution to this. The character stops on each waypoint because it takes time for the moveto task to finish execute and then set the next waypoint on the btt and then continue. This simply is too slow. The update of where the character will move to next must be recalculated at frame speed so the change becomes seemless. This means it must be handled in the tick task.

The approach I took was making a custom task called patrol, which will check each frame if the character has reached the next waypoint and if so, (without aborting), setting and calling moveto to the next waypoint after that.  
Take a look at the btt picture and the code. It will make it easier to understand 🙂

void UBTT\_Patrol::TickTask(UBehaviorTreeComponent& OwnerComp, uint8\* NodeMemory, float DeltaSeconds) { Super::TickTask(OwnerComp, NodeMemory, DeltaSeconds);

AWaypoint\* nextWaypoint = character-\>GetNextWaypoint();  
currentWP = nextWaypoint;  
&nbsp;  
// If there is next waypoint then try moving to it  
if (currentWP != nullptr)  
{  
FVector currentWPLocation = currentWP-\>GetActorLocation(); FVector characterLocation = character-\>GetActorLocation(); currentWPLocation.Z = characterLocation.Z; // to avoid problems with WP and character height difference  
&nbsp;  
// If character already arrived to target  
if (currentWPLocation.Equals(characterLocation, 60.0f))  
{  
bMoving = false;  
&nbsp;  
// Check if target changed  
if (currentWP != nextWaypoint)  
{  
currentWP = nextWaypoint;  
else  
{  
if (bMoving)  
{  
if (currentWP == nextWaypoint)  
{  
bMoving = false;  
}  
else  
{  
// If target changed try moving to it  
currentWP = nextWaypoint;  
ownerController-\>MoveToActor(currentWP, AcceptableRadius, bStopOnOverlap);  
}  
}  
else  
{  
// If not moving move to the waypoint  
ownerController-\>MoveToActor(currentWP, AcceptableRadius, bStopOnOverlap);  
bMoving = true;  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Lordontcare](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lordontcare](https://forums.unrealengine.com/u/Lordontcare)\
**Post date:** [June 9, 2022, 7:51am UTC](https://forums.unrealengine.com/t/character-stopping-before-moving-to-next-waypoint/307417/7 "2022-06-09T07:51:58Z")

</div>

It is very easy, if you change the way of thinking:

Just spawn an invisible actor,  
and let your AI to chase it all the time!  
(By clicking the ‘use continous goal tracking’ optinal on)

And when you change the waypoint,  
just move the invisible actor there,  
no need to call ‘move to’ function again,  
therefore, the character will not stop.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/6/f4607fe4e9bcc65f87bd374a1ea46e36e0f429e8.png)
