Hi,
I’ve done everything I believe correctly. Here’s my OpenDoor.h file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine.h"
//Must be last
#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;
void OpenDoor();
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction*
ThisTickFunction) override;
// This properties are private to OpenDoor only
private:
UPROPERTY(VisibleAnywhere) // Essentially an Unreal property, if you view the OpenDoor in UE4 you'll see
OpenAngle = 90.0 (DOESN'T AUTO COMPLETE)
float OpenAngle = 90.0f;
UPROPERTY(EditAnywhere)
ATriggerVolume* PressurePlate;
UPROPERTY(EditAnywhere)
AActor* ActorThatOpens; // Pawn inherits from Actor so you can use APawn
};
And here is my 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();
OpenDoor();
}
void UOpenDoor::OpenDoor()
{
AActor* Owner = GetOwner(); // It is actually AActor* but you can use auto if you don't know
FRotator NewRotation = FRotator(0.0f, -80.0f, 0.0f); // f means float
Owner->SetActorRotation(NewRotation);
}
// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction*
ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (PressurePlate->IsOverlappingActor(ActorThatOpens)) {
OpenDoor();
}
}
But it’s not triggering the door. Any ideas?