Added off state to traffic lights.

This commit is contained in:
Axel 2020-09-16 13:09:18 +02:00 committed by bernat
parent 7b914bd13a
commit ec7b3b63fd
2 changed files with 22 additions and 3 deletions

View File

@ -97,9 +97,16 @@ void UTrafficLightComponent::SetLightState(ETrafficLightState NewState)
{
Controller->SetTrafficLight(nullptr);
}
// workarround for tm not supporting off state
if (LightState == ETrafficLightState::Off)
{
Controller->SetTrafficLightState(ETrafficLightState::Green);
Controller->SetTrafficLight(nullptr);
}
}
if (LightState == ETrafficLightState::Green)
}
if (LightState == ETrafficLightState::Green ||
LightState == ETrafficLightState::Off)
{
Vehicles.Empty();
}
@ -153,12 +160,18 @@ void UTrafficLightComponent::OnOverlapTriggerBox(UPrimitiveComponent *Overlapped
if (VehicleController)
{
VehicleController->SetTrafficLightState(LightState);
if (LightState != ETrafficLightState::Green)
if (LightState != ETrafficLightState::Green &&
LightState != ETrafficLightState::Off)
{
Vehicles.Add(VehicleController);
VehicleController->SetTrafficLight(
Cast<ATrafficLightBase>(GetOwner()));
}
// workarround for tm not supporting off state
if (LightState == ETrafficLightState::Off)
{
VehicleController->SetTrafficLightState(ETrafficLightState::Green);
}
}
}
}

View File

@ -6,11 +6,17 @@
#pragma once
#include <compiler/disable-ue4-macros.h>
#include <carla/rpc/TrafficLightState.h>
#include <compiler/enable-ue4-macros.h>
#include "TrafficLightState.generated.h"
UENUM(BlueprintType)
enum class ETrafficLightState : uint8 {
Red UMETA(DisplayName = "Red"),
Yellow UMETA(DisplayName = "Yellow"),
Green UMETA(DisplayName = "Green")
Green UMETA(DisplayName = "Green"),
Off UMETA(DisplayName = "Off")
};