CarlaWheeledVehicle: Added for curve/callbacks for timeline
For now, all the logic happens in the TimelineDefault.
This commit is contained in:
parent
4fb8476211
commit
9400f8f546
|
@ -45,6 +45,13 @@ ACarlaWheeledVehicle::ACarlaWheeledVehicle(const FObjectInitializer& ObjectIniti
|
|||
BaseMovementComponent = CreateDefaultSubobject<UBaseCarlaMovementComponent>(TEXT("BaseMovementComponent"));
|
||||
|
||||
DoorTimelineDefault = CreateDefaultSubobject<UTimelineComponent>(TEXT("Timeline"));
|
||||
|
||||
InterpFunction.BindUFunction(this, FName("DoorTimelineUpdate"));
|
||||
TimelineFinished.BindUFunction(this, FName("DoorTimelineFinished"));
|
||||
// TimelineUpdate.BindUFunction(this, FName("DoorTimelineUpdate"));
|
||||
|
||||
//DoorTimelineDefault->SetTimelineLength(5.0f);
|
||||
//DoorTimelineDefault->SetFloatCurve(CurveDoor, TEXT("DoorTimelineCurve"));
|
||||
}
|
||||
|
||||
ACarlaWheeledVehicle::~ACarlaWheeledVehicle() {}
|
||||
|
@ -597,16 +604,14 @@ void ACarlaWheeledVehicle::ConfigureAnimationData()
|
|||
UE_LOG(LogTemp, Warning, TEXT("ACarlaWheeledVehicle::ConfigureAnimationData: DoorAnimAlpha: %d"), DoorAnimAlpha.Num());
|
||||
|
||||
for (int i = 0; i < DoorAnimMaxAngle.Num(); i++) {
|
||||
//DoorAnimAlpha.Emplace(DoorAnimMaxAngle[i] * 2.0f);
|
||||
|
||||
//UE_LOG(LogTemp, Warning, TEXT(" DoorAnimAlpha: %d %d"), DoorAnimAlpha[i], DoorAnimAlpha.Num());
|
||||
//UTimelineComponent* Timeline = CreateDefaultSubobject<UTimelineComponent>(TEXT("Timeline_%d"), i);
|
||||
FName NameTimeline = FName(TEXT("Timeline_%d"), i);
|
||||
UTimelineComponent* Timeline = DuplicateObject<UTimelineComponent>(DoorTimelineDefault, nullptr);
|
||||
DoorTimeline.Add(Timeline);
|
||||
}
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("ACarlaWheeledVehicle::ConfigureAnimationData: DoorTimeline: %d"), DoorTimeline.Num());
|
||||
DoorTimelineDefault->AddInterpFloat(CurveDoor, InterpFunction);
|
||||
DoorTimelineDefault->SetTimelinePostUpdateFunc(TimelineUpdate);
|
||||
DoorTimelineDefault->SetTimelineFinishedFunc(TimelineFinished);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "VehicleAnimInstance.h"
|
||||
#include "MovementComponents/BaseCarlaMovementComponent.h"
|
||||
#include "Components/TimelineComponent.h"
|
||||
#include "Runtime/Engine/Classes/Curves/CurveFloat.h"
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
|
@ -278,6 +279,28 @@ protected:
|
|||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Door Animation")
|
||||
TArray<UTimelineComponent*> DoorTimeline;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Door Animation")
|
||||
class UCurveFloat* CurveDoor;
|
||||
|
||||
FOnTimelineFloat InterpFunction{};
|
||||
FOnTimelineEvent TimelineFinished{};
|
||||
FOnTimelineEvent TimelineUpdate{};
|
||||
|
||||
UFUNCTION()
|
||||
void DoorTimelineUpdate(float value)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("DoorTimelineUpdate: %f"), value);
|
||||
|
||||
for(int i = 0; i < DoorAnimAlpha.Num(); i++)
|
||||
DoorAnimAlpha[i] = value;
|
||||
}
|
||||
|
||||
UFUNCTION()
|
||||
void DoorTimelineFinished()
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("DoorTimelineFinished"));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// Current state of the vehicle controller (for debugging purposes).
|
||||
|
|
Loading…
Reference in New Issue