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;