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!