TickTimeline() Access Violation

I am trying to use a Timeline to animate a button being pressed. Below is the code for the button class

BasicButton.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/Actor.h"
#include "BasicButton.generated.h"

/**
 * 
 */
UCLASS()
class SPACEPUZZLE_API ABasicButton : public AActor
{
	GENERATED_BODY()

		ABasicButton(const class FObjectInitializer& ObjectInitializer);	
		virtual void BeginPlay() override;

		virtual void ReceiveHit
			(
				UPrimitiveComponent* MyComponent,
				AActor* OtherActor,
				UPrimitiveComponent* OtherComponent,
				bool bSelfMoved, FVector HitLocation,
				FVector HitNormal, FVector NormalImpulse,
				const FHitResult& Hit
			) override; //Overide the RecieveHit function from AActor to define custom behaviour

		float DELTATIME;

		UFUNCTION()
			void Anim_UpdateProgress(FVector Vec); // Function that will update the buttons position
		UFUNCTION()
			void Anim_TickTimeline();
		UFUNCTION()
			void Anim_AnimateButton();


protected:	


public:

	//PROPERTY
	UPROPERTY(BlueprintReadWrite, Category = Components)
		UPrimitiveComponent* ButtonMesh; //Pointer to the Buttons MeshComponent (To be set in Blueprints)
	UPROPERTY(BlueprintReadWrite, Category = Components)
		UCurveVector* Anim_VectorCurve;  //Pointer to the Vector Curve used in the Animation Timeline
	UPROPERTY()
		float Anim_DeltaTime; //Stepsize for the timer that will tick the timeline;
	UPROPERTY()
		FTimeline Anim_Timeline; //Timeline that will animate the button

		

	//FUNCTION

};

BasicButton.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "SpacePuzzle.h"
#include "BasicButton.h"

ABasicButton::ABasicButton(const class FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
{
	const ConstructorHelpers::FObjectFinder<UCurveVector> Curve(TEXT("CurveVector'/Game/Blueprints/Functionals/Anim_ButtonCurve.Anim_ButtonCurve'"));
	DELTATIME = 1.f;
	FOnTimelineVector ProgressDelegate{}; //Setup a Delegate to pass the Timeline. Tis will be bound to Anim_UpdateProgress()
	ProgressDelegate.BindUFunction(this, "Anim_UpdateProgress"); // Bind the delegate to our update function
	Anim_Timeline.AddInterpVector(Anim_VectorCurve, ProgressDelegate);    	
}

void ABasicButton::BeginPlay()
{
	Super::BeginPlay();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Using Basic Button"));
	}
}

void ABasicButton::ReceiveHit(UPrimitiveComponent* MyComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("HIT"));
	}

	if (!Anim_Timeline.IsPlaying())
	{
		Anim_AnimateButton();
	}
}



void ABasicButton::Anim_TickTimeline()
{

	if (Anim_Timeline.IsPlaying())
	{		
		Anim_Timeline.TickTimeline(DELTATIME);
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("TRYING TO Tick Timeline!"));
	}
	else
	{
		UWorld* World = GetWorld();
		if (World)
		{
			GetWorldTimerManager().ClearTimer(this, &ABasicButton::Anim_TickTimeline);
		}		
	}
}

void ABasicButton::Anim_UpdateProgress(FVector Vec)
{
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("TRYING TO PLAY"));
	}
	//This function is called when the timline ticks and should move the button
	if (ButtonMesh != NULL)
	{
		FVector MoveLocation = ButtonMesh->GetComponentLocation() + Vec;
		ButtonMesh->MoveComponent(Vec, ButtonMesh->GetComponentRotation(), false);
	}
}

void ABasicButton::Anim_AnimateButton()
{
	//This Function should begin playback of the animation timeline

				

		//Begin a clock that will tick with the timeline
		UWorld* World = GetWorld();
		if (World)
		{
			Anim_Timeline.PlayFromStart();
			FTimerHandle TimerHandle;
			GetWorldTimerManager().SetTimer(TimerHandle, this, &ABasicButton::Anim_TickTimeline, DELTATIME, true, 0.0f);			
		}
	
}

When the Button object receives a Hit the game crashes and gives the following error

Access violation - code c0000005 (first/second chance not available)

UE4Editor_Engine + 2542179 bytes
UE4Editor_Engine + 8907614 bytes
UE4Editor_Engine + 8945910 bytes
UE4Editor_Engine + 9050082 bytes
UE4Editor_SpacePuzzle!ABasicButton::Anim_TickTimeline() + 65 bytes [d:\ut4project\spacepuzzle\source\spacepuzzle\basicbutton.cpp:49]
UE4Editor_Engine + 8866299 bytes
UE4Editor_Engine + 9047929 bytes
UE4Editor_Engine + 5623214 bytes
UE4Editor_UnrealEd + 1803906 bytes
UE4Editor_UnrealEd + 6686342 bytes
UE4Editor!FEngineLoop::Tick() + 3876 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\launchengineloop.cpp:2214]
UE4Editor!GuardedMain() + 479 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\launch.cpp:131]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

Through a process of elimination I have been able to narrow this crash down to the Anim_TickTimeLine() function, specifically the line:

Anim_Timeline.TickTimeline(DELTATIME);

If I comment this line out I see the debug message “Trying to Tick Timeline!” periodically be printed to the screen, until after 5 seconds have passed (The length of the curve) at which point the messages stop.

Can anyone see why the timeline is not ticking? Perhaps there is some initialization required before the timeline is ready to be ticked?

I am still having trouble with this issue. Would someone be able to link me to a working piece of code that deals with timelines (other than the one I linked) for reference?

Hi Men,

You could fix your code?

I’m having the same problem …

You could post the answer here?

I had similar issue, after calling TickTimeline() my game crashed, I tracked it and as callstack says it is caused by FTimeline::GetLastKeyframeTime() and UCurveBase::GetTimeRange().

I figured out that when I set up timeline in constructor using ClimbUpTimeline.AddInterpFloat(ClimbLadderCurve, ClimbUpTimelineDelegate); ClimbLadderCurve is nullptr in constructor, so I moved initialization of timeline to begin play. (ClimbLadderCurve is set up via property in editor)

Everything works now, but anyways, I think there should be one more condition in that internal timeline function, so it will not cause crash, just log would be better. Probably tiny bug.

[2015.07.14-18.54.28:523][566]LogWindows: === Critical error: ===
Fatal error!

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000038

UE4Editor-Engine.dll!UCurveBase::GetTimeRange() (0x000007fedbcdd0e3) + 4 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\curvebase.cpp:788]
UE4Editor-Engine.dll!FTimeline::GetLastKeyframeTime() (0x000007fedc38a799) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\timeline.cpp:526]
UE4Editor-Engine.dll!FTimeline::GetTimelineLength() (0x000007fedc395c46) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\timeline.cpp:460]
UE4Editor-Engine.dll!FTimeline::TickTimeline() (0x000007fedc3b2a32) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\timeline.cpp:363]
UE4Editor-COMGame.dll!ACOMCharacter::Tick() (0x000007fed96d3c12) + 0 bytes [c:\users\ondrej\documents\unreal projects\comgame\source\comgame\comcharacter.cpp:410]
UE4Editor-Engine.dll!AActor::TickActor() (0x000007fedbc137be) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\actor.cpp:660]
UE4Editor-Engine.dll!FActorTickFunction::ExecuteTick() (0x000007fedbbc2564) + 30 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\actor.cpp:119]
UE4Editor-Engine.dll!FTickTaskSequencer::FTickFunctionTask::DoTask() (0x000007fedc376cd6) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\ticktaskmanager.cpp:322]
UE4Editor-Engine.dll!TGraphTask<FTickTaskSequencer::FTickFunctionTask>::ExecuteTask() (0x000007fedc382e7d) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\async\taskgraphinterfaces.h:671]
UE4Editor-Core.dll!FTaskThread::ProcessTasks() (0x000007feebb94fa5) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\async\taskgraph.cpp:428]
UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit() (0x000007feebb9518d) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\async\taskgraph.cpp:271]
UE4Editor-Core.dll!FTaskGraphImplementation::WaitUntilTasksComplete() (0x000007feebbb64ff) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\async\taskgraph.cpp:984]
UE4Editor-Engine.dll!FTaskGraphInterface::WaitUntilTaskCompletes() (0x000007fedc3ba11f) + 16 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\async\taskgraphinterfaces.h:188]
UE4Editor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup() (0x000007fedc3a77d0) + 190 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\ticktaskmanager.cpp:187]
UE4Editor-Engine.dll!FTickTaskManager::RunTickGroup() (0x000007fedc3aa53e) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\ticktaskmanager.cpp:722]
UE4Editor-Engine.dll!UWorld::RunTickGroup() (0x000007fedc004566) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\leveltick.cpp:696]
UE4Editor-Engine.dll!UWorld::Tick() (0x000007fedc00b58b) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\leveltick.cpp:1114]
UE4Editor-UnrealEd.dll!UEditorEngine::Tick() (0x000007fee5dde502) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\editor.cpp:1329]
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() (0x000007fee6298306) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\unrealedengine.cpp:347]
UE4Editor.exe!FEngineLoop::Tick() (0x000000013f720263) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:2257]
UE4Editor.exe!GuardedMain() (0x000000013f71267c) + 0 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor.exe!GuardedMainWrapper() (0x000000013f7126ea) + 5 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor.exe!WinMain() (0x000000013f722219) + 17 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor.exe!__tmainCRTStartup() (0x000000013f723159) + 21 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
kernel32.dll!UnknownFunction (0x00000000778359ed) + 0 bytes [UnknownFile:0]
ntdll.dll!UnknownFunction (0x0000000077a6c541) + 0 bytes [UnknownFile:0]
ntdll.dll!UnknownFunction (0x0000000077a6c541) + 0 bytes [UnknownFile:0]