Bugfix for Overriding Local Rotation on Character Camera

This commit is contained in:
Philip W 2023-05-12 16:32:02 +01:00
parent 73204efa31
commit ec1ebc729d

View File

@ -249,8 +249,7 @@ void ATurnBaseCombatV2::Tick(const float DeltaTime)
{ {
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss"); FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
{ {
FOutputDeviceNull AR; FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true")); const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
@ -270,7 +269,7 @@ void ATurnBaseCombatV2::Tick(const float DeltaTime)
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation()); const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation());
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->SetWorldRotation(LookAtRotation); PlayerController->SetControlRotation(LookAtRotation);
} }
} }
} }