TimeLine c++

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:


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


    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.


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

.cpp in begin play


    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)

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:


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

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?

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


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



        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.

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

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

FOnTimelineFloat InterpFunction;

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 :slight_smile:

I’m happy it worked for you.

For seekers of the old knowledge, it is here: Timeline in C++ (archive)

Copied from: SpaceHarry’s Wiki post, originally sourced from this linked answer.