Finished Door opening mechanic
This commit is contained in:
parent
14c1874c53
commit
55e160eb80
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/DoorPrompt/BP_Door.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/DoorPrompt/BP_Door.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/DoorPrompt/WBP_DoorPrompt.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/DoorPrompt/WBP_DoorPrompt.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:162297ec59b7e47b42f34b19c64b0cbca86fcf80168764e5047cc45910cfe7da
|
|
||||||
size 4366
|
|
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/DoorTestLevel/D/X5/OKD54JHXNGXNVF4JEBBMVP.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/DoorTestLevel/D/X5/OKD54JHXNGXNVF4JEBBMVP.uasset
(Stored with Git LFS)
Binary file not shown.
@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
#include "DoorClass.h"
|
#include "DoorClass.h"
|
||||||
|
|
||||||
|
#include "EndlessVendettaCharacter.h"
|
||||||
|
#include "Components/ArrowComponent.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
ADoorClass::ADoorClass()
|
ADoorClass::ADoorClass()
|
||||||
{
|
{
|
||||||
@ -16,33 +20,43 @@ void ADoorClass::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::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
|
// Called every frame
|
||||||
void ADoorClass::Tick(float DeltaTime)
|
void ADoorClass::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADoorClass::Interact()
|
void ADoorClass::Interact()
|
||||||
{
|
{
|
||||||
if (!IsValid(this)) return;
|
if (!IsValid(this)) return;
|
||||||
GLog->Log("Door has been interacted");
|
|
||||||
bool bIsDoorOpen = false;
|
|
||||||
if (!bIsDoorOpen)
|
if (!bIsDoorOpen)
|
||||||
{
|
{
|
||||||
|
DoorOpeningAnim();
|
||||||
bIsDoorOpen = true;
|
bIsDoorOpen = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DoorCloseAnim();
|
||||||
bIsDoorOpen = false;
|
bIsDoorOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADoorClass::InteractPrompt()
|
void ADoorClass::InteractPrompt()
|
||||||
{
|
{
|
||||||
|
if(bIsDoorOpen) return;
|
||||||
DoorPrompt();
|
DoorPrompt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/ArrowComponent.h"
|
||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include "EndlessVendetta/InteractionInterface.h"
|
#include "EndlessVendetta/InteractionInterface.h"
|
||||||
#include "DoorClass.generated.h"
|
#include "DoorClass.generated.h"
|
||||||
@ -22,6 +23,12 @@ protected:
|
|||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
ACharacter* playerInWorld;
|
||||||
|
|
||||||
|
AEndlessVendettaCharacter* endlessVendettaChar;
|
||||||
|
|
||||||
|
UArrowComponent* FrontOfDoor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
@ -33,4 +40,12 @@ public:
|
|||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void DoorPrompt();
|
void DoorPrompt();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
|
void DoorOpeningAnim();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
|
void DoorCloseAnim();
|
||||||
|
|
||||||
|
bool bIsDoorOpen = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user