0
AWheeledVehicle運動,我試圖將我的車輛(AWheeledVehicle)向前移動。我正確地參考了正確的車輛,但仍然不動。 不知道我在做什麼錯。使用虛幻引擎4的C++
以下附件是我的車和控制器類
AAIWheeledVehicle
AAIWheeledVehicle::AAIWheeledVehicle(){
AIControllerClass = AMyAIVehicleController::StaticClass();
}
AMyAIVehicleController在UE4
void AMyAIVehicleController::Possess(APawn *pawn){
Super::Possess(pawn);
//FVector location2 = pawn->GetActorLocation(); // -11310, 8910, 0
// initialize location of target point
location.X = -9620.0f;
location.Y = 8910.0f;
location.Z = 0.0f;
scaleValue = 1.0f;
target = GetWorld()->SpawnActor<ATargetPoint>(location, FRotator::ZeroRotator);
target->SetActorLocation(location);
// get AI vehicle reference
vehicle = Cast<AWheeledVehicle>(pawn);
// add forward movement to vehicle, scale = 1
vehicle->AddMovementInput(GetActorForwardVector(), scaleValue);
//vehicle->GetVehicleMovement()->Velocity.X = 1.0f;
//vehicle->GetVehicleMovement()->SetThrottleInput(1.0f);
//vehicle->GetVehicleMovement()->SetSteeringInput(1.0f);
//vehicle->GetVehicleMovement()->SetHandbrakeInput(false);
// set rotaion of vehicle to rotation of the target point
vehicle->SetActorRotation(target->GetActorRotation());
}