Download

Rotate and Walk

Im trying to make my patrol fully rotate to the given waypoint before it starts to move.

the patrol rotates to the first waypoint, moves to it but never reaches AlreadyAtGoal, so it never updates ActualRoute for the next waypoint…
When my patrol reaches the first waypoint, he just stays there.
What am i doing wrong?

View of the scene:
eff62a74e353d5bfb5d138a03edb9429903ead82.jpeg

My behaviortree:

d6d24adcafade4123bd2d0d1af0441922ec30ee2.jpeg

My BTTask Rotate and Walk:

183f2451cc3c7f55f2cff146de09c1678b261ce2.jpeg

the Rotate And Walk method:



bool APatrolController::RotateAndWalk(float DeltaTime, float RotationRate)
{
	bool Sucess = false;

	if (Patrol)
	{
		int32 NPaths = Patrol->GetPathsCount();

		if (NPaths > 0)
		{
			if (ActualRoute > NPaths)
				ActualRoute = 1;

			/* Get the vector location of the next waypoint */
			FVector pVector = Patrol->GetPathIndex(ActualRoute);

			FRotator OldRotator = Patrol->GetActorRotation();

			/* Get the rotation that must be made for the waypoint */
			FRotator NewRotator = this->GetPatrolPathRotator(pVector);

			FRotator Received = FMath::RInterpConstantTo(OldRotator, NewRotator, DeltaTime, RotationRate);

			Patrol->SetActorRotation(Received);

			/* If the rotation of the character is complete, move */
			if (OldRotator.Yaw == NewRotator.Yaw)
			{
				switch (this->MoveToLocation(pVector, 10.0F, true, true, false, true, NULL))
				{
				case EPathFollowingRequestResult::AlreadyAtGoal:
					Sucess = true;
					/* Never reaches this code */
					ActualRoute++;
					break;
				case EPathFollowingRequestResult::Failed:
					Sucess = false;
					break;
				case EPathFollowingRequestResult::RequestSuccessful:
					break;
				default:
					break;
				}
			}
		}
	}

	return Sucess;
}


The sucess variable does not change anything.