Finished Door opening mechanic

This commit is contained in:
MH261677 2023-11-21 14:31:33 +00:00
parent 14c1874c53
commit 55e160eb80
6 changed files with 39 additions and 13 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:162297ec59b7e47b42f34b19c64b0cbca86fcf80168764e5047cc45910cfe7da
size 4366

View File

@ -3,6 +3,10 @@
#include "DoorClass.h"
#include "EndlessVendettaCharacter.h"
#include "Components/ArrowComponent.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
ADoorClass::ADoorClass()
{
@ -16,33 +20,43 @@ void ADoorClass::BeginPlay()
{
Super::BeginPlay();
// Attempt to find the player character
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
playerInWorld = Cast<AEndlessVendettaCharacter>(PlayerController->GetCharacter());
endlessVendettaChar = Cast<AEndlessVendettaCharacter>(playerInWorld);
for (UActorComponent* actorComp : playerInWorld->GetComponentsByTag(UArrowComponent::StaticClass(), FName("FrontOfDoor")))
{
FrontOfDoor = Cast<UArrowComponent>(actorComp);
break;
}
}
// Called every frame
void ADoorClass::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ADoorClass::Interact()
{
if (!IsValid(this)) return;
GLog->Log("Door has been interacted");
bool bIsDoorOpen = false;
if (!bIsDoorOpen)
{
DoorOpeningAnim();
bIsDoorOpen = true;
}
else
{
DoorCloseAnim();
bIsDoorOpen = false;
}
}
void ADoorClass::InteractPrompt()
{
if(bIsDoorOpen) return;
DoorPrompt();
}

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "Components/ArrowComponent.h"
#include "GameFramework/Actor.h"
#include "EndlessVendetta/InteractionInterface.h"
#include "DoorClass.generated.h"
@ -21,6 +22,12 @@ public:
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
ACharacter* playerInWorld;
AEndlessVendettaCharacter* endlessVendettaChar;
UArrowComponent* FrontOfDoor;
public:
// Called every frame
@ -33,4 +40,12 @@ public:
UFUNCTION(BlueprintImplementableEvent)
void DoorPrompt();
UFUNCTION(BlueprintImplementableEvent)
void DoorOpeningAnim();
UFUNCTION(BlueprintImplementableEvent)
void DoorCloseAnim();
bool bIsDoorOpen = false;
};