Change autopilot to turn at intersections based on front wheels instead of pivot

This commit is contained in:
nsubiron 2018-06-14 17:20:06 +02:00
parent e67295e4af
commit 9d16e6672e
1 changed files with 7 additions and 1 deletions

View File

@ -203,7 +203,13 @@ void AWheeledVehicleAIController::TickAutopilotController()
float AWheeledVehicleAIController::GoToNextTargetLocation(FVector &Direction)
{
const auto &CurrentLocation = Vehicle->GetActorLocation();
// Get middle point between the two front wheels.
const auto CurrentLocation = [&](){
const auto &Wheels = Vehicle->GetVehicleMovementComponent()->Wheels;
check((Wheels.Num() > 1) && (Wheels[0u] != nullptr) && (Wheels[1u] != nullptr));
return (Wheels[0u]->Location + Wheels[1u]->Location) / 2.0f;
}();
const auto Target = [&](){
const auto &Result = TargetLocations.front();
return FVector{Result.X, Result.Y, CurrentLocation.Z};