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)
Fieol
(Fieol)
December 12, 2019, 10:06am
2
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
Fieol
(Fieol)
December 16, 2019, 5:24am
4
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.
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?
Fieol
(Fieol)
December 16, 2019, 8:10am
6
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
Fieol:
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.
Fieol
(Fieol)
December 16, 2019, 10:40am
8
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
Fieol
(Fieol)
December 17, 2019, 5:51am
10
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
nichaohao
(nichaohao)
December 17, 2019, 6:54am
11
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
Fieol
(Fieol)
December 18, 2019, 6:37am
13
I’m happy it worked for you.
BenVlodgi
(BenVlodgi)
October 3, 2022, 5:18pm
14
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.
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
YourClass(const FObjectInitializer& ObjectInitializer);
UPROPERTY()
UTimelineComponent* ScoreTimeline;
UPROPERTY()
UCurveFloat* fCurve;
FOnTimelineFloat InterpFunction{};
UFUNCTION()
void TimelineFloatReturn(float val);
.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.
YourOtherFloatCurve->GetFloatValue(ScoreTimeline->GetPlaybackposition());
YourOtherVectorCurve->GetVectorValue("");