Updated Interaction.cpp

Script now looks for the camera on the player making it ready to start moving the camera to the items
This commit is contained in:
MH261677 2023-01-16 17:35:11 +00:00
parent ab2d2118dd
commit 7aa3a702d6
2 changed files with 49 additions and 0 deletions

View File

@ -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<UCameraComponent>(TempCharacter->FindComponentByClass<UCameraComponent>());
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<UCameraComponent>(TempCharacter->FindComponentByClass<UCameraComponent>());
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"));
}
}
}

View File

@ -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;
};