CarlaWheeledVehicle: Added Open/Close door functionality
This commit is contained in:
parent
321a4495f6
commit
25412daf93
|
@ -583,3 +583,59 @@ void ACarlaWheeledVehicle::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
|||
{
|
||||
ShowDebugTelemetry(false);
|
||||
}
|
||||
|
||||
void ACarlaWheeledVehicle::OpenDoor(EVehicleDoor DoorIdx) {
|
||||
// We check if the car has any door configured
|
||||
if (DoorAnimMaxAngle.Num() == 0) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("The car has no doors configured."));
|
||||
return;
|
||||
}
|
||||
|
||||
// door exist
|
||||
if (int(DoorIdx) > DoorAnimMaxAngle.Num() && DoorIdx != EVehicleDoor::Door_All) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("This door is not configured for this car."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (DoorIdx == EVehicleDoor::Door_All) {
|
||||
for (int i = 0; i < DoorAnimMaxAngle.Num(); i++)
|
||||
OpenDoorAnim(EVehicleDoor(i));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
OpenDoorAnim(DoorIdx);
|
||||
}
|
||||
|
||||
void ACarlaWheeledVehicle::CloseDoor(EVehicleDoor DoorIdx) {
|
||||
// We check if the car has any door configured
|
||||
if (DoorAnimMaxAngle.Num() == 0) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("The car has no doors configured."));
|
||||
return;
|
||||
}
|
||||
|
||||
// door exist
|
||||
if (int(DoorIdx) > DoorAnimMaxAngle.Num() && DoorIdx != EVehicleDoor::Door_All) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("This door is not configured for this car."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (DoorIdx == EVehicleDoor::Door_All) {
|
||||
for (int i = 0; i < DoorAnimMaxAngle.Num(); i++)
|
||||
CloseDoorAnim(EVehicleDoor(i));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CloseDoorAnim(DoorIdx);
|
||||
}
|
||||
|
||||
void ACarlaWheeledVehicle::OpenDoorAnim_Implementation(EVehicleDoor DoorIdx)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("OpenDoorAnim_Implementation."));
|
||||
}
|
||||
|
||||
void ACarlaWheeledVehicle::CloseDoorAnim_Implementation(EVehicleDoor DoorIdx)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("CloseDoorAnim_Implementation."));
|
||||
}
|
||||
|
|
|
@ -42,6 +42,17 @@ enum class EVehicleWheelLocation : uint8 {
|
|||
Back_Wheel = 1,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EVehicleDoor : uint8 {
|
||||
Door_FL = 0,
|
||||
Door_FR = 1,
|
||||
Door_RL = 2,
|
||||
Door_RR = 3,
|
||||
Door_Hood = 4,
|
||||
Door_Truck = 5,
|
||||
Door_All = 99
|
||||
};
|
||||
|
||||
/// Base class for CARLA wheeled vehicles.
|
||||
UCLASS()
|
||||
class CARLA_API ACarlaWheeledVehicle : public AWheeledVehicle
|
||||
|
@ -251,6 +262,12 @@ protected:
|
|||
UFUNCTION(BlueprintCallable, CallInEditor)
|
||||
void AdjustVehicleBounds();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Door Animation")
|
||||
TArray<float> DoorAnimAlpha;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Door Animation")
|
||||
TArray<float> DoorAnimMaxAngle;
|
||||
|
||||
private:
|
||||
|
||||
/// Current state of the vehicle controller (for debugging purposes).
|
||||
|
@ -285,6 +302,22 @@ public:
|
|||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation);
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
void OpenDoor(EVehicleDoor DoorIdx);
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
void CloseDoor(EVehicleDoor DoorIdx);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "CARLA Wheeled Vehicle")
|
||||
void OpenDoorAnim(EVehicleDoor DoorIdx);
|
||||
|
||||
virtual void OpenDoorAnim_Implementation(EVehicleDoor DoorIdx);
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "CARLA Wheeled Vehicle")
|
||||
void CloseDoorAnim(EVehicleDoor DoorIdx);
|
||||
|
||||
virtual void CloseDoorAnim_Implementation(EVehicleDoor DoorIdx);
|
||||
|
||||
virtual FVector GetVelocity() const override;
|
||||
|
||||
//-----CARSIM--------------------------------
|
||||
|
|
Loading…
Reference in New Issue