Hello, I am trying to convert this Blueprint event with a timeline node from existing blueprint to C++
I have this timeline node within the blueprint code and I am trying to figure out how to reference these pins from the event in the callback functions.
Here is the Blueprint Code
Here is the header file
// Sets default values for this actor's properties
AActorBase();
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Object Transform Timeline")
void TIMELINE_MoveSceneComponentToTransform(UObject* CallingObject, USceneComponent* MovingComponent, FTransform StartTransform, FTransform EndTransform, float Speed, ETimeline_Mode PlayMode);
UPROPERTY(BlueprintReadWrite)
UTimelineComponent* ObjectTransformTimeline;
UPROPERTY(EditAnywhere, Category = "Object Transform Timeline")
UCurveFloat* FloatCurve;
// This is the Update Part
UFUNCTION()
void ObjectTransformFloatReturn(float Value);
UFUNCTION()
void OnObjectTransformTimelineFinished();
/* Declare our delegate function to be binded with ObjectTransformFloatReturn */
FOnTimelineFloat InterpFunction{};
/* Declare our delegate function to be binded with OnObjectTransformTimelineFinished */
FOnTimelineEvent TimelineFinished{};
Here is the cpp file
AActorBase::AActorBase()
{
ObjectTransformTimeline = CreateDefaultSubobject<UTimelineComponent>(TEXT("Timeline"));
InterpFunction.BindUFunction(this, FName("ObjectTransformFloatReturn"));
TimelineFinished.BindUFunction(this, FName("OnObjectTransformTimelineFinished"));
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
void AActorBase::TIMELINE_MoveSceneComponentToTransform_Implementation(UObject* CallingObject, USceneComponent* MovingComponent, FTransform StartTransform, FTransform EndTransform, float Speed, ETimeline_Mode PlayMode)
{
// Allow Speed up to 5x and speed down to 0.01x
const float NewValue = FMath::Clamp(Speed, 0.01f, 5.0f);
// Update the Timeline Speed
ObjectTransformTimeline->SetPlayRate(NewValue);
switch(PlayMode)
{
case ETimeline_Mode::Play:
ObjectTransformTimeline->Play();
break;
case ETimeline_Mode::PlayFromStart:
ObjectTransformTimeline->PlayFromStart();
break;
case ETimeline_Mode::Stop:
ObjectTransformTimeline->Stop();
break;
case ETimeline_Mode::Reverse:
ObjectTransformTimeline->Reverse();
break;
case ETimeline_Mode::ReverseFromEnd:
ObjectTransformTimeline->SetNewTime(0.0f);
break;
default:
break;
}
}
void AActorBase::ObjectTransformFloatReturn(float Value)
{
}
void AActorBase::OnObjectTransformTimelineFinished()
{
}
// Called when the game starts or when spawned
void AActorBase::BeginPlay()
{
Super::BeginPlay();
// Check if curve asset reference is valid
if (FloatCurve)
{
// Add the float curve to the timeline and connect it to the interpfunction's delegate
ObjectTransformTimeline->AddInterpFloat(FloatCurve, InterpFunction, FName("Alpha"));
// Add our on timeline finished function
ObjectTransformTimeline->SetTimelineFinishedFunc(TimelineFinished);
// Setting our timeline's settings before we play it
ObjectTransformTimeline->SetLooping(false);
ObjectTransformTimeline->SetIgnoreTimeDilation(true);
}
}
For the two callbacks ObjectTransformFloatReturn and OnObjectTransformTimelineFinished
how DO I get the event’s execution data pins in those functions?
In OnObjectTransformTimelineFinished I want CallingObject but I have no way to access it?
I hope that makes sense and I can try to clarify if need by.