Hello, pawn movement doesn’t work neither with blueprint nor with C++.
I have a code:
Var.1
void AEnemyAIController::BeginPlay()
{
Super::BeginPlay();
DeltaTimeToFollow = FMath::RandRange(0.1f, 0.4f);
FTimerHandle ExplodeTimerHandle;
GetWorldTimerManager().SetTimer(ExplodeTimerHandle, this, &AEnemyAIController::FollowPlayer, DeltaTimeToFollow, true);
}
void AEnemyAIController::FollowPlayer()
{
float AcceptableRadius = FMath::RandRange(8.0f, 10200.0f);
EPathFollowingRequestResult::Type FollowResult;
FollowResult = MoveToLocation(GetCharacterLocation(), AcceptableRadius);
FString DebugText = UEnum::GetValueAsString(FollowResult);
UE_LOG(LogTemp, Warning, TEXT("%s"), *DebugText);
}
Var.2
void AEnemyAIController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
TryToMove();
}
void AEnemyAIController::TryToMove()
{
FRotator Rotation = GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);//Get the forward vector
SelfPawn->AddMovementInput(Direction, 1.0f);
}
DebugText is always EPathFollowingRequestResult::RequestSuccessful.
NavMesh set up right, AiController posesses the Pawn.
Screenshots from BP: Imgur: The magic of the Internet