# TimeLine c++

**URL:** <https://forums.unrealengine.com/t/timeline-c/134833>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [December 11, 2019, 12:52pm UTC](https://forums.unrealengine.com/t/timeline-c/134833 "2019-12-11T12:52:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2dd84d5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2dd84d5a](https://forums.unrealengine.com/u/anonymous_user_2dd84d5a)\
**Post date:** [December 11, 2019, 12:52pm UTC](https://forums.unrealengine.com/t/timeline-c/134833/1 "2019-12-11T12:52:54Z")

</div>

Hello,  
I am trying to use a timeline to make a camera effect when i dash.  
But when i press play the Engine Collapses with this exeption:  
Exception thrown at 0x00007FFD4278C9E1 (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000118.  
in:

```auto

void FTimeline::AddInterpFloat(UCurveFloat* FloatCurve, FOnTimelineFloat InterpFunc, FName PropertyName, FName TrackName)
{
    FTimelineFloatTrack NewEntry;
    NewEntry.FloatCurve = FloatCurve;
    NewEntry.InterpFunc = InterpFunc;
    NewEntry.TrackName = TrackName;
    NewEntry.FloatPropertyName = PropertyName;

    InterpFloats.Add(NewEntry);
}

```

my .h

```auto

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TimeLine")
    class UTimelineComponent* DashTimeLine;

    UFUNCTION()
    void DashTimelineUpdate(float val);

    FOnTimelineFloat InterpFunction{};

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TimeLine")
    class UCurveFloat* fCurve;

```

.cpp in the constractor.

```auto

    DashTimeLine = CreateDefaultSubobject<UTimelineComponent>(TEXT("DashTimeLine"));
    InterpFunction.BindUFunction(this, FName("DashTimelineUpdate"));

```

.cpp in begin play

```auto

    if(fCurve)
    {
        DashTimeLine->AddInterpFloat(fCurve, InterpFunction, FName("Alpha"));
        DashTimeLine->SetLooping(false);
        DashTimeLine->SetIgnoreTimeDilation(true);
    }

```

when i click on wasd twice in a row it fires DashTimeLine-\>PlayFromStart();  
If anyone can tell me what goes wrong that would be helpful (I didn’t add all the .h and .cpp because it’s a mess but if its needed tell me and ill add it)

---

<div class="post-metadata">

**Author:** ![Fieol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fieol/32/1104383_2.png) [@Fieol](https://forums.unrealengine.com/u/Fieol)\
**Post date:** [December 12, 2019, 10:06am UTC](https://forums.unrealengine.com/t/timeline-c/134833/2 "2019-12-12T10:06:48Z")

</div>

Plase share what line you are getting the error on ? Have you tried attaching a debbuger and please share a log of it, and what line it came ?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2dd84d5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2dd84d5a](https://forums.unrealengine.com/u/anonymous_user_2dd84d5a)\
**Post date:** [December 12, 2019, 12:53pm UTC](https://forums.unrealengine.com/t/timeline-c/134833/3 "2019-12-12T12:53:15Z")

</div>

> [@Fieol](#):
>
> Plase share what line you are getting the error on ? Have you tried attaching a debbuger and please share a log of it, and what line it came ?

here:

```auto

InterpFloats.Add(NewEntry);

```

It crushes with Exception thrown at 0x00007FFD4278C9E1 (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000118  
TrackName = “None” and FloatProperty= Null

---

<div class="post-metadata">

**Author:** ![Fieol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fieol/32/1104383_2.png) [@Fieol](https://forums.unrealengine.com/u/Fieol)\
**Post date:** [December 16, 2019, 5:24am UTC](https://forums.unrealengine.com/t/timeline-c/134833/4 "2019-12-16T05:24:25Z")

</div>

This could be trivial, there could be possible cases like :

- InterFloats data type variable is null.
- The array of this datatype could have read limits or capacity limits.

Check if the value is coming in the data type in debugger. (null pointer check)

Check if the value is allowed to be set in the array.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2dd84d5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2dd84d5a](https://forums.unrealengine.com/u/anonymous_user_2dd84d5a)\
**Post date:** [December 16, 2019, 7:37am UTC](https://forums.unrealengine.com/t/timeline-c/134833/5 "2019-12-16T07:37:29Z")

</div>

> [@Fieol](#):
>
> This could be trivial, there could be possible cases like :
> 
> - InterFloats data type variable is null.
> - The array of this datatype could have read limits or capacity limits.
> 
> Check if the value is coming in the data type in debugger. (null pointer check)
> 
> Check if the value is allowed to be set in the array.

I cant edit the file because it is read only but when it steps there it doesn’t seem to be nullptr.  
About the second advice how do i check if the array is set to read and write?

---

<div class="post-metadata">

**Author:** ![Fieol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fieol/32/1104383_2.png) [@Fieol](https://forums.unrealengine.com/u/Fieol)\
**Post date:** [December 16, 2019, 8:10am UTC](https://forums.unrealengine.com/t/timeline-c/134833/6 "2019-12-16T08:10:42Z")

</div>

I think if you look at your error, it clearly mentions

```auto

Access violation reading location 0x0000000000000118

```

With this we can assume that the Array is not allowed to write or read that way. You need to figure out other ways to set the values inside this data member. Try looking at more functions in the Unreal Engine API

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2dd84d5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2dd84d5a](https://forums.unrealengine.com/u/anonymous_user_2dd84d5a)\
**Post date:** [December 16, 2019, 8:57am UTC](https://forums.unrealengine.com/t/timeline-c/134833/7 "2019-12-16T08:57:08Z")

</div>

> [@Fieol](#):
>
> I think if you look at your error, it clearly mentions
> 
> ```auto
> 
> Access violation reading location 0x0000000000000118
> 
> ```
> 
> With this we can assume that the Array is not allowed to write or read that way. You need to figure out other ways to set the values inside this data member. Try looking at more functions in the Unreal Engine API

Is there a way to make timeline work without

```auto

        FOnTimelineFloat DashTimelineUpdate;
        DashTimelineUpdate.BindUFunction(this, FName("DashTimelineUpdate"));

```

It crushes when it tries to bind the function and the function is public so i don’t get what could cause access violation.

---

<div class="post-metadata">

**Author:** ![Fieol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fieol/32/1104383_2.png) [@Fieol](https://forums.unrealengine.com/u/Fieol)\
**Post date:** [December 16, 2019, 10:40am UTC](https://forums.unrealengine.com/t/timeline-c/134833/8 "2019-12-16T10:40:53Z")

</div>

Oh! Thanks for sharing that debug information.

There are other delegate ways to bind the function. Try UObject as well and let me know

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2dd84d5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2dd84d5a](https://forums.unrealengine.com/u/anonymous_user_2dd84d5a)\
**Post date:** [December 16, 2019, 2:48pm UTC](https://forums.unrealengine.com/t/timeline-c/134833/9 "2019-12-16T14:48:38Z")

</div>

> [@Fieol](#):
>
> Oh! Thanks for sharing that debug information.
> 
> There are other delegate ways to bind the function. Try UObject as well and let me know

How do i bind it as Uobject because it doesnt seem to have any options like so in the FTimeline.cpp

---

<div class="post-metadata">

**Author:** ![Fieol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fieol/32/1104383_2.png) [@Fieol](https://forums.unrealengine.com/u/Fieol)\
**Post date:** [December 17, 2019, 5:51am UTC](https://forums.unrealengine.com/t/timeline-c/134833/10 "2019-12-17T05:51:49Z")

</div>

There should be a timeline c++ tutorial which can help you here . Did you try opening a wiki of this given topic ? Something like this [A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums](https://wiki.unrealengine.com/Timeline_in_c%2B%2B)

---

<div class="post-metadata">

**Author:** ![nichaohao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nichaohao](https://forums.unrealengine.com/u/nichaohao)\
**Post date:** [December 17, 2019, 6:54am UTC](https://forums.unrealengine.com/t/timeline-c/134833/11 "2019-12-17T06:54:04Z")

</div>

FOnTimelineFloat InterpFunction;

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2dd84d5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2dd84d5a](https://forums.unrealengine.com/u/anonymous_user_2dd84d5a)\
**Post date:** [December 17, 2019, 9:17am UTC](https://forums.unrealengine.com/t/timeline-c/134833/12 "2019-12-17T09:17:28Z")

</div>

> [@Fieol](#):
>
> There should be a timeline c++ tutorial which can help you here . Did you try opening a wiki of this given topic ? Something like this [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/Timeline_in_c%2B%2B)

I used It as written in the wiki this time and it worked but i wonder why it didn’t work for me the first time  
Thank you anyway 🙂

---

<div class="post-metadata">

**Author:** ![Fieol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fieol/32/1104383_2.png) [@Fieol](https://forums.unrealengine.com/u/Fieol)\
**Post date:** [December 18, 2019, 6:37am UTC](https://forums.unrealengine.com/t/timeline-c/134833/13 "2019-12-18T06:37:17Z")

</div>

I’m happy it worked for you.

---

<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:18pm UTC](https://forums.unrealengine.com/t/timeline-c/134833/14 "2022-10-03T17:18:52Z")

</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("");
> > 
> > ```
