Updated Interaction,TempCharacter.cpp
Removed the code from TempCharacter from last commit and created a new function Inside of Interaction that activates the TempCharacter.cpp InputEnabler()
This commit is contained in:
parent
d658c63627
commit
11e6393726
@ -9,6 +9,7 @@
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Components/WidgetComponent.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||
|
||||
|
||||
// Sets default values
|
||||
@ -24,9 +25,8 @@ void AInteraction::BeginPlay()
|
||||
Super::BeginPlay();
|
||||
|
||||
//Character refs
|
||||
TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter();
|
||||
MainCamera = Cast<UCameraComponent>(TempCharacter->FindComponentByClass<UCameraComponent>());
|
||||
|
||||
TempCharacterRef = Cast<ATempCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter());
|
||||
MainCamera = Cast<UCameraComponent>(TempCharacterRef->FindComponentByClass<UCameraComponent>());
|
||||
//Item refs
|
||||
|
||||
TargetHealingLocation = HealingItem->GetActorLocation();
|
||||
@ -57,6 +57,7 @@ void AInteraction::BeginPlay()
|
||||
BuyHealingTextWidget->AddToViewport();
|
||||
//We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self
|
||||
BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor");
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
@ -118,7 +119,7 @@ void AInteraction::RemoveWidget()
|
||||
void AInteraction::CameraLeftMover()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed"));
|
||||
if (TempCharacter == nullptr || BuyHealingProperty == nullptr)
|
||||
if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp"));
|
||||
return;
|
||||
@ -148,7 +149,7 @@ void AInteraction::CameraLeftMover()
|
||||
void AInteraction::CameraRightMover()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed"));
|
||||
if (TempCharacter == nullptr || BuyBuffProperty == nullptr)
|
||||
if (TempCharacterRef == nullptr || BuyBuffProperty == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp"));
|
||||
return;
|
||||
@ -181,15 +182,20 @@ void AInteraction::CancelPurchase()
|
||||
BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
}
|
||||
|
||||
void AInteraction::HealingPurchase()
|
||||
void AInteraction::ExitScreen()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AInteraction::BuffPurchase()
|
||||
{
|
||||
|
||||
if (TempCharacterRef == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("TempCharacterRef in Interaction.cpp not found"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
TempCharacterRef->InputEnabler();
|
||||
ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||
#include "Interaction.generated.h"
|
||||
|
||||
UCLASS()
|
||||
@ -70,9 +71,6 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
|
||||
UCameraComponent* MainCamera;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player")
|
||||
ACharacter* TempCharacter;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items")
|
||||
AActor* HealingItem;
|
||||
|
||||
@ -83,10 +81,10 @@ public:
|
||||
virtual void CancelPurchase();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ConfirmButtons")
|
||||
virtual void HealingPurchase();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ConfirmButtons")
|
||||
virtual void BuffPurchase();
|
||||
virtual void ExitScreen();
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Player")
|
||||
ATempCharacter* TempCharacterRef;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -161,7 +161,6 @@ void ATempCharacter::InputEnabler()
|
||||
ThisCamera->SetWorldLocation(OriginalCameraLocation);
|
||||
ThisCamera->SetWorldRotation(OriginalCameraRotation);
|
||||
ThisCamera->FieldOfView = OriginalCameraFOV;
|
||||
ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
//ulog the originalcameralocation value
|
||||
UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString());
|
||||
}
|
||||
|
@ -31,12 +31,9 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true"))
|
||||
class UInventoryComponent* Inventory; //Using the InventoryComponent class
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ItemSelector")
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
|
||||
UUserWidget* ItemSelectorWidget;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Widgets")
|
||||
TSubclassOf<UUserWidget> ItemSelector;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
Loading…
Reference in New Issue
Block a user