Project Crashing on Launch

While working on Section 4 - Lecture 109, I added this bit of code:

	if (!PressurePlate)
	{
		FString ActorName = GetOwner()->GetName();
		UE_LOG(LogTemp, Error, TEXT("%s has the OpenDoor Component attached but no PressurePlate."), *ActorName);
	}

Full cpp file:

// Copyright 2020


#include "OpenDoor.h"
#include "GameFramework/Actor.h"

// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	if (!PressurePlate)
	{
		FString ActorName = GetOwner()->GetName();
		UE_LOG(LogTemp, Error, TEXT("%s has the OpenDoor Component attached but no PressurePlate set."), *ActorName);
	}
	
}


// Called when the game starts
void UOpenDoor::BeginPlay()
{
	Super::BeginPlay();

	InitialYaw = GetOwner()->GetActorRotation().Yaw;
	CurrentYaw = InitialYaw;
	TargetYaw += InitialYaw; // Set target Yaw as initial Yaw + 90 degrees

}


// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (PressurePlate && PressurePlate->IsOverlappingActor(ActorThatOpen))
	{
		OpenDoor(DeltaTime);
	}

}

void UOpenDoor::OpenDoor(float DeltaTime)
{
	CurrentYaw = FMath::Lerp(CurrentYaw, TargetYaw, DeltaTime * 1.f); // Get current Yaw each frame
	FRotator DoorRotation = GetOwner()->GetActorRotation(); // Get the current FRotator each frame
	DoorRotation.Yaw = CurrentYaw; // Interpolate between current and target Yaw
	GetOwner()->SetActorRotation(DoorRotation); // Set interpolated value as new Yaw value

}

And after compiling, my project crashed and I’m now unable to open the project. Every time I launch, I get the error below.

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000018

UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\build\++ue4\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:933]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\build\++ue4\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:1022]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(FName,bool)>::ExecuteIfSafe() [d:\build\++ue4\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:854]
UE4Editor_Core!TBaseMulticastDelegate<void,FName,bool>::Broadcast() [d:\build\++ue4\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:1013]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\build\++ue4\sync\engine\source\runtime\core\private\modules\modulemanager.cpp:493]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\build\++ue4\sync\engine\source\runtime\projects\private\moduledescriptor.cpp:554]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\build\++ue4\sync\engine\source\runtime\projects\private\projectmanager.cpp:63]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3517]
UE4Editor!FEngineLoop::PreInitPostStartupScreen() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2889]
UE4Editor!GuardedMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launch.cpp:131]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
UE4Editor!WinMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:263]
UE4Editor!__scrt_common_main_seh() [d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

It seems like I just need to revert the change I made but I, unfortunately, haven’t set up any sort of source control yet and I can’t open the project in order to compile the cpp after reverting the change manually.

You can try to delete the following folders: Binaries, Build, Intermediate, Saved with Unreal closed. Then open it and rebuild when prompted.

This is an issue as this is the constructor. The owner isn’t set yet as the constructor is run before it’s attached to anything. You will need to move this out of the constructor and into BeginPlay and then compile which you can do via VS Code

Ctrl + Shift + B > ProjectNameEditor Platform Development Build

Where ProjectName is the name of your project and Platform is the platform you’re targeting e.g. Win64

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms