Shiggi
(Shiggi)
September 19, 2016, 7:52pm
1
Hi everyone!
I spawn a unit from blueprint, and make him a move to location from c++. I’m using SimpleMoveToLocation when my unit BeginPlay. But after spawn my unit stend on started location (in Log my scripts started).
That strange, but If I place unit to scene (from editor) he move to target correctly.
I have no idea what I’m doing wrong…
Shiggi
(Shiggi)
September 20, 2016, 8:47am
2
That my code:
void AUnitController::MoveUnitTo(FVector Target)
{
UE_LOG(LogTemp, Warning, TEXT("Start MoveUnitTo"));
APawn* const Pawn = GetPawn();
if (Pawn)
{
UNavigationSystem* const NavSys = GetWorld()->GetNavigationSystem();
UE_LOG(LogTemp, Warning, TEXT("Pawn is %s"), *Pawn->GetName());
UE_LOG(LogTemp, Warning, TEXT("Target location %s"), *Target.ToString());
NavSys->SimpleMoveToLocation(this, Target);
}
}
LOG:
LogTemp:Warning: GameUnit_C_0 - move to target
LogTemp:Warning: Start MoveUnitTo
LogTemp:Warning: Pawn is GameUnit_C_0
LogTemp:Warning: Target location X=40.000 Y=70.000 Z=10.000
Pawn settings:
FloatingPawnMovement settings:
Shiggi
(Shiggi)
September 20, 2016, 2:04pm
3
Problem solwed! I spawn jast a pawn… after need spawn controller and posses them to actor. Or use SpawnAIFromClass…