Hi. I am trying to open the door in my scene by the default pawn. The door has Actor component ‘ManualDoor’ assigned to it. I created child class derived from ManualDoor, called RemoteOpen2 and assigned it to the default pawn. when I manually tick the exposed door open boolean on the door during pause play, the door opens successfully. The RemoteOpen2 class has input binding function that change the door open boolean. Base on the output log, the function (DoorState()) is called and boolean (BIsDoorOpen) is changed successfully, but the door won’t open as if I am accessing a different instance of the boolean. Any idea? Thank you
ManualDoor.h
#include "Components/AudioComponent.h"
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "ManualDoor.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYCASTLE_API UManualDoor : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UManualDoor();
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditInstanceOnly)
bool BIsDoorOpen = false;
virtual void DoorState();
void DoorIsOpening(float DeltaTime);
void DoorIsClosing(float DeltaTIme);
ManualDoor.cpp
void UManualDoor::DoorState()
{
UE_LOG(LogTemp, Warning, TEXT("remote access successful!!"));
if(!BIsDoorOpen)
{
BIsDoorOpen = true;
UE_LOG(LogTemp, Warning, TEXT("open?"));
}
else
{
BIsDoorOpen = false;
UE_LOG(LogTemp, Warning, TEXT("close?"));
}
}
void UManualDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if(BIsDoorOpen)
{
DoorIsOpening(DeltaTime);
DoorLastOpened = GetWorld()->GetTimeSeconds();
}
else
{
if(GetWorld()->GetTimeSeconds() - DoorLastOpened > DoorCloseDelay)
{
DoorIsClosing(DeltaTime);
}
}
// ...
}
RemoteOpen2.h
#include "CoreMinimal.h"
#include "MyCastle/ManualDoor/ManualDoor.h"
#include "RemoteOpen2.generated.h"
/**
*
*/
UCLASS()
class MYCASTLE_API URemoteOpen2 : public UManualDoor
{
GENERATED_BODY()
private:
UPROPERTY()
UInputComponent* InputComponent = nullptr;
void SetupInputComponent();
protected:
virtual void BeginPlay() override;
};
RemoteOpen2.cpp
#include "RemoteOpen2.h"
#include "MyCastle/ManualDoor/ManualDoor.h"
void URemoteOpen2::BeginPlay()
{
Super::BeginPlay();
SetupInputComponent();
}
void URemoteOpen2::SetupInputComponent()
{
InputComponent = GetOwner()->FindComponentByClass<UInputComponent>();
if(InputComponent)
{
InputComponent->BindAction("OpenDoor", IE_Pressed, this, &UManualDoor::DoorState);
}
}
Everytime I pressed “open door” key, the log shows
It means that I am indeed altering the value of BIsDoorOpen but it does not tirgger the tick component to open the door. This is where I got stuck.