Updated Combat so that the Camera Stays Locked on During Combat
This commit is contained in:
parent
dd72b47a6d
commit
73204efa31
BIN
Content/BlueprintAI/AI/AIBruh.uasset
(Stored with Git LFS)
BIN
Content/BlueprintAI/AI/AIBruh.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/BookCombat_UI.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/BookCombat_UI.uasset
(Stored with Git LFS)
Binary file not shown.
@ -18,6 +18,7 @@
|
|||||||
// Sets default values
|
// Sets default values
|
||||||
ATurnBaseCombatV2::ATurnBaseCombatV2()
|
ATurnBaseCombatV2::ATurnBaseCombatV2()
|
||||||
{
|
{
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
if (HUDWidget == nullptr)
|
if (HUDWidget == nullptr)
|
||||||
{
|
{
|
||||||
static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI"));
|
static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI"));
|
||||||
@ -57,37 +58,12 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
|
|||||||
PlayerController->SetInputMode(FInputModeGameAndUI());
|
PlayerController->SetInputMode(FInputModeGameAndUI());
|
||||||
PlayerController->bShowMouseCursor = true;
|
PlayerController->bShowMouseCursor = true;
|
||||||
|
|
||||||
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
// FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||||
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);
|
// Direction.Normalize();
|
||||||
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
|
// FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||||
{
|
// const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
|
||||||
FOutputDeviceNull AR;
|
// LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||||
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
|
// PlayerController->SetControlRotation(LookAtRotation);
|
||||||
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, 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);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation());
|
|
||||||
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
|
||||||
PlayerController->SetControlRotation(LookAtRotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
|
||||||
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
||||||
@ -266,6 +242,39 @@ void ATurnBaseCombatV2::BeginPlay()
|
|||||||
HealButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::HealButtonOnClick);
|
HealButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::HealButtonOnClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATurnBaseCombatV2::Tick(const float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
if (bIsInCombat)
|
||||||
|
{
|
||||||
|
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
||||||
|
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||||
|
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);
|
||||||
|
if (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
|
||||||
|
{
|
||||||
|
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(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation());
|
||||||
|
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||||
|
Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->SetWorldRotation(LookAtRotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||||
{
|
{
|
||||||
if (!IsValidCombo(Combo))
|
if (!IsValidCombo(Combo))
|
||||||
|
@ -121,6 +121,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
void ExecuteCast(FString Combo);
|
void ExecuteCast(FString Combo);
|
||||||
void UseActionPoint();
|
void UseActionPoint();
|
||||||
void ReuseActionPoint();
|
void ReuseActionPoint();
|
||||||
|
Loading…
Reference in New Issue
Block a user