Unreal engine 4 closes after pressing C

I am following along with the 3rd person power up game with c++ tutorial. I believe I’ve done everything in the video correctly. After I key mapped C to pick up the batteries, when I try to pick up the batteries using c, the game closes on me. The unreal engine directly exit It does give me this information:


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


UE4Editor_BatteryCollector_3766!APickup::SetActive() [c:\users\owner\documents\unreal projects\batterycollector\source\batterycollector\pickup.cpp:42]
UE4Editor_BatteryCollector_3766!ABatteryCollectorCharacter::CollectPickups() [c:\users\owner\documents\unreal projects\batterycollector\source\batterycollector\batterycollectorcharacter.cpp:142]
UE4Editor_Engine!FInputActionUnifiedDelegate::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\classes\components\inputcomponent.h:181]
UE4Editor_Engine!UPlayerInput::ProcessInputStack() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\userinterface\playerinput.cpp:1117]
UE4Editor_Engine!APlayerController::ProcessPlayerInput() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\playercontroller.cpp:2281]
UE4Editor_Engine!APlayerController::TickPlayerInput() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\playercontroller.cpp:3824]
UE4Editor_Engine!APlayerController::PlayerTick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\playercontroller.cpp:1950]
UE4Editor_Engine!APlayerController::TickActor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\playercontroller.cpp:3900]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\actor.cpp:107]
UE4Editor_Engine!FTickFunctionTask::DoTask() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\ticktaskmanager.cpp:141]
UE4Editor_Engine!TGraphTask::ExecuteTask() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\async\taskgraphinterfaces.h:779]
UE4Editor_Core!FTaskThread::ProcessTasks() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\async\taskgraph.cpp:539]
UE4Editor_Core!FTaskThread::ProcessTasksUntilQuit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\async\taskgraph.cpp:340]
UE4Editor_Core!FTaskGraphImplementation::WaitUntilTasksComplete() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\async\taskgraph.cpp:1140]
UE4Editor_Engine!FTaskGraphInterface::WaitUntilTaskCompletes() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\async\taskgraphinterfaces.h:212]
UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\ticktaskmanager.cpp:285]
UE4Editor_Engine!FTickTaskManager::RunTickGroup() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\ticktaskmanager.cpp:1206]
UE4Editor_Engine!UWorld::RunTickGroup() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\leveltick.cpp:701]
UE4Editor_Engine!UWorld::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\leveltick.cpp:1150]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\unrealed\private\editorengine.cpp:1347]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\unrealed\private\unrealedengine.cpp:361]
UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:2427]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]

It crashes on \batterycollector\pickup.cpp file, on line 42. You are doing something here that makes the game crash…

change so that press other key to pick up? C could mean close to UE for som reason

Hey Hauetan-

As Michaël Dubé mentioned, the error seems to come from the pickup.cpp file. Can you post the header/source file for this class for more information?


Doug Wilson

Hi Hauetan,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

Sorry, it’s been awhile. I have been busy with college and working. Here is the source file’s code.

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

#include "BatteryCollector.h"
#include "Pickup.h"

// Sets default values
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = false;

	//All pickups start active
	bIsActive = true;

	//Create the static mesh component
	PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
	RootComponent = PickupMesh;

// Called when the game starts or when spawned
void APickup::BeginPlay()

// Called every frame
void APickup::Tick( float DeltaTime )
	Super::Tick( DeltaTime );

// Returns active state
bool APickup::IsActive() 
	return bIsActive;

// Changes active state
void APickup::SetActive(bool NewPickupState)
	bIsActive = NewPickupState;

void APickup::WasCollected_Implementation()
	//Log a debug message
	FString PickupDebugString = GetName();
	UE_LOG(LogClass, Log, TEXT("You have collected %s"), *PickupDebugString);

The callstack mentions the SetActive function which appears to be setup correctly. I’m curious if the information passed to it from ABatteryCollectorCharacter::CollectPickups() is bad. Can you post the CollectPickups() function as well as the log files from the crash? I ran through the battery collector tutorial and did not receive a crash so it may be helpful if you could send a zip of your project as well.

void ABatteryCollectorCharacter::CollectPickups()
// Get all overlapping Actors and store them in an array

	// For each Actor we collected
	for (int32 iCollected = 0; iCollected < CollectedActors.Num(); ++iCollected)

	// Cast the actor to APickup
		APickup* const TestPickup = Cast < APickup >(CollectedActors[iCollected]);
	// If the cast is succesful and the pickup is valid and active.
		if (TestPickup && !TestPickup->IsPendingKill() && TestPickup->IsActive())
	// call the pickup's WasCollected function
	//Deactivate the pickup

link text

How do I export the entire project? I went to file → export all. But it’s saying the file type is not permitted, when I try and export the project on ue4 answerhub.

Rather than exporting the project if you create a zip file of the project folder you can send that easily.

I went to “packaged projects” and from there to zipping up the project. But when I try to upload the zipped project which I saved to my desktop it says,“no such upload.”

Hey Hauetan-

If you are attempting to upload the project here on AnswerHub, please try again to attach the project. Sometimes AnswerHub does not register when trying to add images or other attachments to a post. Additionally, can you let me know if you’re still getting a crash if you run through the tutorial videos in the latest engine version (4.12.2)?

link text
so it’ll let me upload this, but not the zipped battery collector project.

I am not sure what to do. I’m mainly having trouble with the pickup tutorial. But for now I think i’ll just continue the tutorial and see if I run into any other errors that’ll lead me back to where the original problem is.

If you’re unable to attach the project directly, you can try to upload it to google drive or dropbox and provide a download link instead.

Heres a download link from google drive, let me know if it’s the correct link otherwise ill look further into sending the correct link.Google Drive: Sign-in

Google Drive: Sign-in Heres a shareable link. This should work.

I found the problem while doing the next video, and I beheaded it. It was a dang bracket within an if statement. Just a bracket and it caused the game to exit haha