From 6d2d0d8146b043a40500244398a19f466de2d7c4 Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 6 Jun 2024 00:16:23 +0100 Subject: [PATCH] Introduce separate boolean for LookingAtPlayer and FollowPlayer --- Source/tank/CameraVolume.cpp | 2 +- Source/tank/CameraVolume.h | 2 +- Source/tank/SplineCameraVolume.cpp | 7 +++++-- Source/tank/SplineCameraVolume.h | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/tank/CameraVolume.cpp b/Source/tank/CameraVolume.cpp index 5d1a36e..9bdc1bc 100644 --- a/Source/tank/CameraVolume.cpp +++ b/Source/tank/CameraVolume.cpp @@ -30,7 +30,7 @@ void ACameraVolume::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); - if (IsActive && FollowPlayer && TankPlayerCharacter) + if (IsActive && LookAtPlayer && TankPlayerCharacter) { TankPlayerCharacter->CameraComponent->SetWorldRotation(UKismetMathLibrary::FindLookAtRotation( ArrowComponent->GetComponentTransform().GetLocation(), TankPlayerCharacter->GetTransform().GetLocation())); diff --git a/Source/tank/CameraVolume.h b/Source/tank/CameraVolume.h index c9f25c6..c9e3281 100644 --- a/Source/tank/CameraVolume.h +++ b/Source/tank/CameraVolume.h @@ -25,7 +25,7 @@ public: UCameraComponent* DebugCamera; UPROPERTY(EditAnywhere, BlueprintReadWrite) - bool FollowPlayer = false; + bool LookAtPlayer = false; protected: UPROPERTY() diff --git a/Source/tank/SplineCameraVolume.cpp b/Source/tank/SplineCameraVolume.cpp index 9447e14..01ffa27 100644 --- a/Source/tank/SplineCameraVolume.cpp +++ b/Source/tank/SplineCameraVolume.cpp @@ -9,7 +9,6 @@ ASplineCameraVolume::ASplineCameraVolume() { SplineComponent = CreateDefaultSubobject(TEXT("Spline Component")); SplineComponent->SetupAttachment(RootComponent); - FollowPlayer = true; } void ASplineCameraVolume::BeginPlay() @@ -25,7 +24,11 @@ void ASplineCameraVolume::Tick(float DeltaSeconds) TankPlayerCharacter->GetTransform().GetLocation(), ESplineCoordinateSpace::World); TankPlayerCharacter->CameraComponent->SetWorldLocation(Location); + } + + if (IsActive && LookAtPlayer && TankPlayerCharacter) + { TankPlayerCharacter->CameraComponent->SetWorldRotation(UKismetMathLibrary::FindLookAtRotation( - Location, TankPlayerCharacter->GetTransform().GetLocation())); + TankPlayerCharacter->GetTransform().GetLocation(), TankPlayerCharacter->GetTransform().GetLocation())); } } diff --git a/Source/tank/SplineCameraVolume.h b/Source/tank/SplineCameraVolume.h index b37e873..146db17 100644 --- a/Source/tank/SplineCameraVolume.h +++ b/Source/tank/SplineCameraVolume.h @@ -19,6 +19,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite) USplineComponent* SplineComponent; + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool FollowPlayer = true; + ASplineCameraVolume(); virtual void BeginPlay() override;