# How to create a Timeline in C++?

**URL:** <https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 13, 2014, 8:29pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029 "2014-10-13T20:29:55Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![BenVlodgi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benvlodgi/32/1194567_2.png) [@BenVlodgi](https://forums.unrealengine.com/u/BenVlodgi)\
**Post date:** [October 3, 2022, 5:01pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/15 "2022-10-03T17:01:36Z")

</div>

For seekers of the old knowledge, it is here: [Timeline in C++ (archive)](https://web.archive.org/web/20161223202125/https://wiki.unrealengine.com/Timeline_in_c%2B%2B)

Copied from: [SpaceHarry](https://forums.unrealengine.com/u/spaceharry/summary)’s Wiki post, originally sourced from this linked answer.

> [@Link to timelines doc for c++?](https://forums.unrealengine.com/t/link-to-timelines-doc-for-c/349439/7):
>
> # How to use Timeline in c++
> 
> This example maybe gives you an idea about how to use Timelines in c++.
> 
> ##### It was tested on 4.10, but it should also work on other version in a similar way.
> 
> ##### Disclaimer: This wiki combines previous examples from Answerhub and Forum and adds on top of it, that you dont need the actors tick component where u place the timeline.
> 
> ## .h
> 
> > ```auto
> > YourClass(const FObjectInitializer& ObjectInitializer);
> >  
> > UPROPERTY()
> > UTimelineComponent* ScoreTimeline;
> >  
> > UPROPERTY()
> > UCurveFloat* fCurve;
> >  
> > FOnTimelineFloat InterpFunction{};
> >  
> > UFUNCTION()
> > void TimelineFloatReturn(float val);
> > 
> > ```
> 
> ## .cpp
> 
> > ```cpp
> > // Constructor
> > AYourClass::AYourClass(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
> > {
> > static ConstructorHelpers::FObjectFinder<UCurveFloat> Curvy(TEXT("Reference Path to your Float Curve"));
> > if (Curvy.Object)
> > {
> > fCurve = Curvy.Object;
> > }
> > 	
> > ScoreTimeline = ObjectInitializer.CreateDefaultSubobject<UTimelineComponent>(this, TEXT("TimelineScore"));
> > 	
> > //Bind the Callbackfuntion for the float return value
> > InterpFunction.BindUFunction(this, FName{ TEXT("TimelineFloatReturn") });
> > }
> >  
> >  
> > //BeginPlay
> > void AYourClass::BeginPlay()
> > {
> > //Add the float curve to the timeline and connect it to your timelines's interpolation function
> > ScoreTimeline->AddInterpFloat(fCurve, InterpFunction, FName{ TEXT("Floaty") });
> >  
> > // Start your Timeline or PlayFromStart() etc, can be called anywhere in this class
> > ScoreTimeline->Play();
> > }
> >  
> >  
> > //Your Callback Function for the timeline float value
> > void AYourClass::TimelineFloatReturn(float val)
> > {
> > //Your float val from curve returns here
> > }
> > 
> > ```
> 
> If at the same time you would like to get the return value from another float or vector curve in your return function, then just get the playback position of your timeline and and get the corresponding return value from your curve.
> 
> > ```cpp
> > YourOtherFloatCurve->GetFloatValue(ScoreTimeline->GetPlaybackposition());
> > YourOtherVectorCurve->GetVectorValue("");
> > 
> > ```

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029)._
