i want implemet stops on 3 seconds on waypoints for my AI, but it doesn’t work correctly.
I have some problems with SetTimer function, so my bot stops near the waypont but he can not continue his way to the next point, so waypoints working properly and bot patrolling(if i’m not trying to implement stops:D)
void AAI_Bot_Controller::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
AAi_Bot_Character* Character = Cast<AAi_Bot_Character>(GetPawn());
if (Character->NextWaypoint != nullptr)
{
MoveToActor(Character->NextWaypoint, 5.0f);
if (Character->GetDistanceTo(Character->NextWaypoint) < 150.0f) {
if (bBotWaypointStop) {
Character->GetCharacterMovement()->MaxWalkSpeed = 0;
}
else {
Character->GetCharacterMovement()->MaxWalkSpeed = 150;
}
}
GetWorld()->GetTimerManager().SetTimer(Handle, this, &AAI_Bot_Controller::ContinueWalking, 3.0f, false);
}
}
void AAI_Bot_Controller::ContinueWalking()
{
bBotWaypointStop = false;
GetWorldTimerManager().ClearTimer(Handle);
}