Introduce separate boolean for LookingAtPlayer and FollowPlayer
This commit is contained in:
parent
66a782609d
commit
6d2d0d8146
|
@ -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()));
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue