Bugfix Camera Shake Due to Spam of Animations
This commit is contained in:
parent
ec1ebc729d
commit
afd166c868
@ -58,19 +58,27 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
|
||||
PlayerController->SetInputMode(FInputModeGameAndUI());
|
||||
PlayerController->bShowMouseCursor = true;
|
||||
|
||||
// FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||
// Direction.Normalize();
|
||||
// FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||
// const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
|
||||
// LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||
// PlayerController->SetControlRotation(LookAtRotation);
|
||||
|
||||
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
|
||||
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
||||
const FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
|
||||
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
|
||||
EnemyHealth = EnemyHealthPtr;
|
||||
|
||||
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||
if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
|
||||
{
|
||||
FOutputDeviceNull AR;
|
||||
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
|
||||
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
||||
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
|
||||
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||
LookAtRotation.Pitch += 10; //Offset
|
||||
PlayerController->SetControlRotation(LookAtRotation);
|
||||
}
|
||||
|
||||
if (IsValid(CombatTutorialWidgetInstance) && CombatTutorialWidgetInstance->IsInViewport()) return;
|
||||
if (!HasSeenTutorial)
|
||||
{
|
||||
@ -249,20 +257,7 @@ void ATurnBaseCombatV2::Tick(const float DeltaTime)
|
||||
{
|
||||
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
||||
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||
if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
|
||||
{
|
||||
FOutputDeviceNull AR;
|
||||
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
|
||||
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
||||
|
||||
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
|
||||
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||
PlayerController->SetControlRotation(LookAtRotation);
|
||||
}
|
||||
else
|
||||
if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); !IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
|
||||
{
|
||||
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
|
Loading…
Reference in New Issue
Block a user