From 14c7d6b6d7860e5820adfc4dc9fa04942cbeb241 Mon Sep 17 00:00:00 2001
From: MH261677 <mh261677@falmouth.ac.uk>
Date: Sat, 4 Feb 2023 18:34:53 +0000
Subject: [PATCH] Updated TempCharacter.cpp

Cached the camera reference isntead of constantly casting for it
---
 Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp
index aed31e5..f6c743b 100644
--- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp
+++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp
@@ -24,6 +24,7 @@ void ATempCharacter::BeginPlay()
 {
 	Super::BeginPlay();
 	Health = 100;
+	ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
 }
 
 //Binds the input we made in the setup player component to the forward vector
@@ -147,7 +148,6 @@ void ATempCharacter::InputDisabler()
 	GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true;
 	GetWorld()->GetFirstPlayerController()->bEnableClickEvents = true;
 	GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = true;
-	ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
 	if (ThisCamera == nullptr)
 	{
 		return;
@@ -173,7 +173,6 @@ void ATempCharacter::InputEnabler()
 	GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false;
 	//GetWorld()->GetFirstPlayerController()->InputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed);
 	TraceDistance = 300;
-	ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
 	if (ThisCamera == nullptr)
 	{
 		return;