From 7aa3a702d6504e4a76080b4cca98f34843542051 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 16 Jan 2023 17:35:11 +0000 Subject: [PATCH] Updated Interaction.cpp Script now looks for the camera on the player making it ready to start moving the camera to the items --- .../MerchantInteraction/Interaction.cpp | 42 +++++++++++++++++++ .../MerchantInteraction/Interaction.h | 7 ++++ 2 files changed, 49 insertions(+) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index df602b7..b6f63ab 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -3,8 +3,10 @@ #include "Interaction.h" +#include "NetworkMessage.h" #include "Chaos/BoundingVolumeUtilities.h" #include "Components/Button.h" +#include "GameFramework/Character.h" #include "Components/WidgetComponent.h" @@ -77,9 +79,49 @@ void AInteraction::RemoveWidget() void AInteraction::CameraLeftMover() { UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); + TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); + MainCamera = Cast(TempCharacter->FindComponentByClass()); + if (TempCharacter == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); + return; + } + else + { + UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp")); + if (MainCamera == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp")); + return; + } + else + { + UE_LOG(LogTemp, Display, TEXT("Camera functionality here in Interaction.cpp")); + } + } } void AInteraction::CameraRightMover() { UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); + TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); + MainCamera = Cast(TempCharacter->FindComponentByClass()); + if (TempCharacter == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); + return; + } + else + { + UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp")); + if (MainCamera == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp")); + return; + } + else + { + UE_LOG(LogTemp, Display, TEXT("Camera functionality here in Interaction.cpp")); + } + } } diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 0c41e49..4231b2a 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "Camera/CameraComponent.h" #include "GameFramework/Actor.h" #include "Interaction.generated.h" @@ -50,5 +51,11 @@ public: UFUNCTION(BlueprintCallable, Category= "ButtonLeft") virtual void CameraRightMover(); + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera") + UCameraComponent* MainCamera; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player") + ACharacter* TempCharacter; };