diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp index 6f09d772d..194c72399 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp @@ -18,7 +18,7 @@ // -- Static local methods ----------------------------------------------------- // ============================================================================= -static bool RayTrace(const AActor &Actor, const FVector &Start, const FVector &End) +static bool RayCast(const AActor &Actor, const FVector &Start, const FVector &End) { FHitResult OutHit; static FName TraceTag = FName(TEXT("VehicleTrace")); @@ -32,6 +32,9 @@ static bool RayTrace(const AActor &Actor, const FVector &Start, const FVector &E FCollisionObjectQueryParams(FCollisionObjectQueryParams::AllDynamicObjects), CollisionParams); + // DrawDebugLine(Actor.GetWorld(), Start, End, + // Success ? FColor(255, 0, 0) : FColor(0, 255, 0), false); + return Success && OutHit.bBlockingHit; } @@ -60,9 +63,9 @@ static bool IsThereAnObstacleAhead( const FVector EndLeft = StartLeft + NormDirection * (Distance + VehicleBounds.X / 2.0f); return - RayTrace(Vehicle, StartCenter, EndCenter) || - RayTrace(Vehicle, StartRight, EndRight) || - RayTrace(Vehicle, StartLeft, EndLeft); + RayCast(Vehicle, StartCenter, EndCenter) || + RayCast(Vehicle, StartRight, EndRight) || + RayCast(Vehicle, StartLeft, EndLeft); } template @@ -204,6 +207,7 @@ void AWheeledVehicleAIController::TickAutopilotController() else { Steering = CalcStreeringValue(Direction); + Direction = Vehicle->GetVehicleTransform().GetRotation().Rotator().Vector(); } // Speed in km/h. diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h index f475afcb9..b7d9a734c 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h @@ -234,6 +234,7 @@ private: // =========================================================================== // -- Member variables ------------------------------------------------------- // =========================================================================== + /// @{ private: