7#include "Kismet/GameplayStatics.h"
8#include "Components/SceneCaptureComponent2D.h"
9#include "Components/PrimitiveComponent.h"
30 UGameplayStatics::GetAllActorsOfClass(WorldContextObject, ASensor::StaticClass(),
Sensors);
32 for (AActor* SensorActor :
Sensors)
34 ASensor* sensor = Cast<ASensor>(SensorActor);
35 if (sensor !=
nullptr)
46 TArray<AActor*> Vehicles;
47 UGameplayStatics::GetAllActorsOfClass(WorldContextObject, AVehicle::StaticClass(), Vehicles);
48 for (AActor* Actor : Vehicles)
53 auto* SensorManager =
Vehicle->GetSensorsManager();
56 SensorManager->DestroyAllSensors();
65 UGameplayStatics::GetAllActorsOfClass(WorldContextObject, ASensor::StaticClass(),
Sensors);
66 for (AActor* SensorActor :
Sensors)
68 ASensor* Sensor = Cast<ASensor>(SensorActor);
71 bool AllowedToDestroy =
true;
72 if (!DestroyDefaultVehicleSensors)
82 AllowedToDestroy =
false;
111 UE_LOG(LogTemp, Warning, TEXT(
"vehicle is nullptr. Returning."));
117 TArray<AActor*> Actors;
118 Vehicle->GetAttachedActors(Actors);
120 for (AActor* actor : Actors)
122 ASensor* sensor = Cast<ASensor>(actor);
132 if (PrimitiveComponent)
static void HideComponentForAllCameras(UPrimitiveComponent *PrimitiveComponent)
virtual ESensorTypes GetSensorType() const
void SetSimulateSensor(bool SimulateSensor)
static void SetSimulateAllSensors(const UObject *WorldContextObject, bool SimulateSensors)
static void EnableSensorsAttachedToVehicle(AVehicle *Vehicle)
static void SetSimulateSensorsAttachedToVehicle(AVehicle *Vehicle, bool SimulateSensors)
static void DestroyAllSensors(const UObject *WorldContextObject, bool DestroyDefaultVehicleSensors=false)
static void HideComponentForAllCameraSensors(UPrimitiveComponent *PrimitiveComponent)
static void EnableAllSensors(const UObject *WorldContextObject)
static void DisableSensorsAttachedToVehicle(AVehicle *Vehicle)
static void DisableAllSensors(const UObject *WorldContextObject)