Actor moving faster than Timeline

Hello everyone,

I’m facing a trouble with my timeline. I have a platform and I’m using a timeline to move that platform.

I’ve set a variable to control the time (TravelTimeInSeconds) that my platform will take to move from the initial point to the end point in seconds. Whatever is the value I set, the platform always take less time than I set.

I’m using FMath::Lerp(), and the alpha value is the float value of my curve, and the time from 0 to 1 takes exactly the time I set, but the actor is moving more faster than that.

Example: if I set 5 seconds, the float value will take 5 seconds from 0 to 1.

I made a gif to show what I’m saying.

Here it is the video link if you want to see with more resolution

And this is my C++ code


#pragma once
#include "GameFramework/Actor.h"
#include "MovablePlatform.generated.h"
class PROJECTHEC_API AMovablePlatform : public AActor

	virtual void PostInitializeComponents() override;

	class USceneComponent* Root;

	class UPaperSpriteComponent* SpriteMovablePlatform;

	class UPaperSprite* SourceMovablePlatform;

	// The end location where is the platform will go
	UPROPERTY(EditAnywhere, Category = PlatformControls)
	FVector EndLocation;

	// Storing the initial location of the actor
	FVector InitialLocation;

	// The time that the platform will take to get to the end location
	UPROPERTY(EditAnywhere, Category = PlatformControls)
	float TravelTimeInSeconds;

	// The time the platform will stay stoped 
	UPROPERTY(EditAnywhere, Category = PlatformControls)
	float StopDelay = 0.0f;

	// Just to test the end location of the platform 
	UPROPERTY(EditAnywhere, Category = PlatformControls)
	bool bTestEndLocation = false;

	UPROPERTY(EditAnywhere, Category = PlatformControls)
	bool bOrientationAxisX;

	UPROPERTY(EditAnywhere, Category = PlatformControls)
	bool bOrientationAxisZ;

	void MovePlatform(float Value);

	class UCurveFloat* TimelineCurve;

	FTimeline PlatformTimeline;


#include "ProjectHEC.h"
#include "MovablePlatform.h"
#include "PaperSpriteComponent.h"
#include "Runtime/Engine/Classes/Components/TimelineComponent.h"

// Sets default values
 	// 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;

	ConstructorHelpers::FObjectFinderOptional<UPaperSprite> MovablePlatformAsset(TEXT("PaperSprite'/Game/Sprites/Ledge.Ledge'"));
	SourceMovablePlatform = MovablePlatformAsset.Get();

	Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
	RootComponent = Root;

	SpriteMovablePlatform = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("MovablePlatform"));

	//Timeline - Try later
	ConstructorHelpers::FObjectFinder<UCurveFloat> Curve(TEXT("CurveFloat'/Game/Data/TimelineCurve.TimelineCurve'"));
	TimelineCurve = Curve.Object;
	PlatformTimeline = FTimeline{};
	FOnTimelineFloat InterpFunc{};
	InterpFunc.BindUFunction(this, FName("MovePlatform"));
	PlatformTimeline.AddInterpFloat(TimelineCurve, InterpFunc, FName("PlatformTimeline"));

void AMovablePlatform::PostInitializeComponents()

	InitialLocation = GetActorLocation();
	EndLocation += InitialLocation;

// Called when the game starts or when spawned
void AMovablePlatform::BeginPlay()


// Called every frame
void AMovablePlatform::Tick( float DeltaTime )
	Super::Tick( DeltaTime );


void AMovablePlatform::MovePlatform(float Value)
	EndLocation = FMath::Lerp(EndLocation, InitialLocation, TimelineCurve->GetFloatValue(Value));

	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::, FString::SanitizeFloat(Value));

If anyone could help me with this issue I’ll be grateful

PS.: Sorry for my English or if I wrote anything wrong.


Is it ok to change the EndLocation value and set it to the result of the Lerp? instead of using a local variable? The Lerp values should not change, except the alpha. I ask because I have never used timelines or Lerps in code, so I’m not sure.

I believe is on the right track. From what I understand, alpha values will usually take any number you give them, but it’ll either ignore anything not between 0 and 1 or it’ll clamp it to be in that range. That could be contributing of the issue you’re experiencing.

It worked, I just created a local variable to receive the result from lerp like said.

Thanks all of you