EDIT: I created the OpenDoor component within the Door actor, but apparently Unreal glitched and created OpenDoor but didn’t actually associate it with the Door. Just dragged OpenDoor from the Content Browser down below and dropped it in the Door’s details.
After following all the instructions in this lesson to make edits to the OpenDoor.cpp, saving, compiling, and hitting play, the door remains in the 0 degree closed position. The code did absolutely nothing to change the position of my door. My 2x1_Door_and_Frame_Door actor is set to “Movable” in the Mobility section. Below is the code within OpenDoor.cpp.
// Fill out your copyright notice in the Description page of Project Settings.
#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();
FRotator CurrentRotation = GetOwner()->GetActorRotation();
CurrentRotation.Yaw = 90.f;
GetOwner()->SetActorRotation(CurrentRotation);
}
// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
Here’s the OpenDoor.h if that helps:
// 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 BUILDING_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;
};