Unreal crashing when opened

Hi there, so I was doing the Unreal Engine course on Udemy, and I was in the lectured called: “Using GetTimeSeconds()” and in one of the compiles I did Unreal crashed, I tried opening unreal again by clicking: “Send and restart” and it opened but it instantly crashed. I tried undoing anything I could have done to crash it in my cpp file and saving it, but it didn’t work. I now can’t even open the editor, what should I do?

Here is my code (cpp):

#include "Engine/World.h"
#include "GameFramework/Controller.h"
#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;

	// ...
}


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

	if (!PressurePlate)
	{
		UE_LOG(LogTemp, Error, TEXT("%s has the door assigned, but not the pressure plate."), *GetOwner()->GetName());
	}
	
	ActorThatOpen = GetWorld()->GetFirstPlayerController()->GetPawn();
}


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

	if (PressurePlate && PressurePlate->IsOverlappingActor(ActorThatOpen))
	{
		OpenDoor(DeltaTime);
		DoorLastOpened = GetWorld()->GetTimeSeconds();
	}
	else
	{
		if (DoorLastOpened == DoorCloseDelay)
		{
			CloseDoor(DeltaTime);
		}
	}
}

void UOpenDoor::OpenDoor(float DeltaTime)
{
	FRotator OpenDoor(0.f, TargetYaw, 0.f);
	OpenDoor.Yaw = FMath::Lerp(GetOwner()->GetActorRotation().Yaw, TargetYaw, DeltaTime * 2.f);
	GetOwner()->SetActorRotation(OpenDoor);
}

void UOpenDoor::CloseDoor(float DeltaTime)
{
	FRotator OpenDoor(0.f, TargetYawClose, 0.f);
	OpenDoor.Yaw = FMath::Lerp(GetOwner()->GetActorRotation().Yaw, TargetYawClose, DeltaTime * 1.f);
	GetOwner()->SetActorRotation(OpenDoor);
}

And here is my header file:

#pragma once
#include "Engine/TriggerVolume.h"
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILD_ESCAPE_API UOpenDoor : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UOpenDoor();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	void OpenDoor(float DeltaTime);
	void CloseDoor(float DeltaTime);
private:
	UPROPERTY(EditAnywhere)
	float TargetYaw = 90.f;
	float TargetYawClose = 0.f;

	float DoorLastOpened = 0.f;
	float DoorCloseDelay = 2.f;

	UPROPERTY(EditAnywhere)
	ATriggerVolume* PressurePlate;

	UPROPERTY(EditAnywhere)
	AActor* ActorThatOpen;
};

Also, if it helps, here is the crash message:

Thanks, in advanced!

Hi, I don’t know how to fix it but you could try deleting the “Binaries” folder inside your project’s folder. Might help

It didn’t work

Hi, you could try deleting all the code that you added to header and source files and then starting the unreal. If the crash is gone after that then you can start adding back your code piece by piece and see if the crash appears again

Did you compile after doing that? If you didn’t then the changes wouldn’t have been applied and Unreal is still running the project with the incorrect code.

To build 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

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

Privacy & Terms