Introduce separate boolean for LookingAtPlayer and FollowPlayer

This commit is contained in:
baz 2024-06-06 00:16:23 +01:00
parent 66a782609d
commit 6d2d0d8146
4 changed files with 10 additions and 4 deletions

View File

@ -30,7 +30,7 @@ void ACameraVolume::Tick(float DeltaSeconds)
{ {
Super::Tick(DeltaSeconds); Super::Tick(DeltaSeconds);
if (IsActive && FollowPlayer && TankPlayerCharacter) if (IsActive && LookAtPlayer && TankPlayerCharacter)
{ {
TankPlayerCharacter->CameraComponent->SetWorldRotation(UKismetMathLibrary::FindLookAtRotation( TankPlayerCharacter->CameraComponent->SetWorldRotation(UKismetMathLibrary::FindLookAtRotation(
ArrowComponent->GetComponentTransform().GetLocation(), TankPlayerCharacter->GetTransform().GetLocation())); ArrowComponent->GetComponentTransform().GetLocation(), TankPlayerCharacter->GetTransform().GetLocation()));

View File

@ -25,7 +25,7 @@ public:
UCameraComponent* DebugCamera; UCameraComponent* DebugCamera;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool FollowPlayer = false; bool LookAtPlayer = false;
protected: protected:
UPROPERTY() UPROPERTY()

View File

@ -9,7 +9,6 @@ ASplineCameraVolume::ASplineCameraVolume()
{ {
SplineComponent = CreateDefaultSubobject<USplineComponent>(TEXT("Spline Component")); SplineComponent = CreateDefaultSubobject<USplineComponent>(TEXT("Spline Component"));
SplineComponent->SetupAttachment(RootComponent); SplineComponent->SetupAttachment(RootComponent);
FollowPlayer = true;
} }
void ASplineCameraVolume::BeginPlay() void ASplineCameraVolume::BeginPlay()
@ -25,7 +24,11 @@ void ASplineCameraVolume::Tick(float DeltaSeconds)
TankPlayerCharacter->GetTransform().GetLocation(), ESplineCoordinateSpace::World); TankPlayerCharacter->GetTransform().GetLocation(), ESplineCoordinateSpace::World);
TankPlayerCharacter->CameraComponent->SetWorldLocation(Location); TankPlayerCharacter->CameraComponent->SetWorldLocation(Location);
}
if (IsActive && LookAtPlayer && TankPlayerCharacter)
{
TankPlayerCharacter->CameraComponent->SetWorldRotation(UKismetMathLibrary::FindLookAtRotation( TankPlayerCharacter->CameraComponent->SetWorldRotation(UKismetMathLibrary::FindLookAtRotation(
Location, TankPlayerCharacter->GetTransform().GetLocation())); TankPlayerCharacter->GetTransform().GetLocation(), TankPlayerCharacter->GetTransform().GetLocation()));
} }
} }

View File

@ -19,6 +19,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
USplineComponent* SplineComponent; USplineComponent* SplineComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool FollowPlayer = true;
ASplineCameraVolume(); ASplineCameraVolume();
virtual void BeginPlay() override; virtual void BeginPlay() override;