Friction Trigger volumes getting spawned with box extents + solved a bug

This commit is contained in:
Manish 2019-04-18 12:57:50 +02:00
parent 70442e2436
commit d832a19028
3 changed files with 31 additions and 4 deletions

View File

@ -43,8 +43,8 @@ void AFrictionTrigger::OnTriggerBeginOverlap(
bool /*bFromSweep*/,
const FHitResult & /*SweepResult*/)
{
ACarlaWheeledVehicle *Vehicle = CastChecked<ACarlaWheeledVehicle>(OtherActor);
if (Vehicle)
ACarlaWheeledVehicle *Vehicle = Cast<ACarlaWheeledVehicle>(OtherActor);
if (Vehicle != nullptr)
{
TArray<float> WheelsFrictionScale = Vehicle->GetWheelsFrictionScale();
for (auto &FrictionScale : WheelsFrictionScale)
@ -62,8 +62,8 @@ void AFrictionTrigger::OnTriggerEndOverlap(
UPrimitiveComponent * /*OtherComp*/,
int32 /*OtherBodyIndex*/)
{
ACarlaWheeledVehicle *Vehicle = CastChecked<ACarlaWheeledVehicle>(OtherActor);
if (Vehicle)
ACarlaWheeledVehicle *Vehicle = Cast<ACarlaWheeledVehicle>(OtherActor);
if (Vehicle != nullptr)
{
TArray<float> WheelsFrictionScale = Vehicle->GetWheelsFrictionScale();
for (auto &FrictionScale : WheelsFrictionScale)

View File

@ -43,6 +43,11 @@ public:
Episode = &InEpisode;
}
void SetBoxExtent(const FVector &Extent)
{
TriggerVolume->SetBoxExtent(Extent);
}
protected:
virtual void BeginPlay() override;

View File

@ -65,6 +65,28 @@ FActorSpawnResult ATriggerFactory::SpawnActor(
auto *Episode = GameInstance->GetCarlaEpisode();
check(Episode != nullptr);
Trigger->SetEpisode(*Episode);
FVector Extent {100.0f, 100.0f, 100.0f};
auto *ExtentX = Description.Variations.Find("extent_x");
if (ExtentX != nullptr)
{
Extent.X = std::atof(TCHAR_TO_UTF8(*ExtentX->Value));
}
auto *ExtentY = Description.Variations.Find("extent_y");
if (ExtentY != nullptr)
{
Extent.Y = std::atof(TCHAR_TO_UTF8(*ExtentY->Value));
}
auto *ExtentZ = Description.Variations.Find("extent_z");
if (ExtentZ != nullptr)
{
Extent.Z = std::atof(TCHAR_TO_UTF8(*ExtentZ->Value));
}
Trigger->SetBoxExtent(Extent);
}
UGameplayStatics::FinishSpawningActor(Trigger, Transform);
return FActorSpawnResult{Trigger};