Here is the OpenDoor.cpp:
// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
InitialYaw = GetOwner()->GetActorRotation().Yaw;
CurrentYaw = InitialYaw;
TargetYaw = InitialYaw + 90;
}
// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// FRotator OpenNinety = GetOwner()->GetActorRotation();
// OpenNinety.Yaw = OpenNinety.Yaw + 90.f;
// GetOwner()->SetActorRotation(OpenNinety);
UE_LOG(LogTemp, Warning, TEXT("%s"), *GetOwner()->GetActorRotation().ToString());
UE_LOG(LogTemp, Warning, TEXT("The Yaw of the Door is: %f"),GetOwner()->GetActorRotation().Yaw);
CurrentYaw = FMath::InterpTo(CurrentYaw, TargetYaw, DeltaTime, 45);
FRotator DoorRotation = GetAOwner()->GetActorRotation();
DoorRotation.Yaw = CurrentYaw;
GetOwner()->SetActorRotation(DoorRotation);
}
and the OpenDoor.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_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;
private:
float InitialYaw;
float CurrentYaw;
float TargetYaw = 90;
};
However, like I said, I changed the code since it began crashing, but I cannot compile it because it never opens the editor, so that is the reason, I believe, it keeps returning the error. But maybe I am missing something else as well