Bugfix Clicking Instantly Activates Combat

This commit is contained in:
Philip W 2023-01-31 00:30:45 +00:00
parent e91d059c56
commit 0de2753dff
5 changed files with 27 additions and 22 deletions

BIN
Content/BlueprintAI/AI/AIBruh.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Top_layer_level.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -37,17 +37,22 @@ void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FAct
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
//If the player is holding down the right mouse button for 3 seconds, then the player will enter combat mode
if (bRightClickDown && RightClickDownTime < 0.1f)
// //If the player is holding down the right mouse button for 3 seconds, then the player will enter combat mode
// if (bRightClickDown && RightClickDownTime < 0.1f)
// {
// RightClickDownTime += DeltaTime;
// }
// else if (bRightClickDown && RightClickDownTime >= 0.1f)
// {
// //Enter Combat Mode
// Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
// //UBlackboardComponent* TargetEnemyBlackboard = Cast<UBlackboardComponent>(TargetEnemy->GetComponentByClass(UBlackboardComponent::StaticClass()));
// //TargetEnemyBlackboard->SetValueAsBool("IsInCombat", true);
// OnRightClickUp();
// }
if (bRightClickDown)
{
RightClickDownTime += DeltaTime;
}
else if (bRightClickDown && RightClickDownTime >= 0.1f)
{
//Enter Combat Mode
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
//UBlackboardComponent* TargetEnemyBlackboard = Cast<UBlackboardComponent>(TargetEnemy->GetComponentByClass(UBlackboardComponent::StaticClass()));
//TargetEnemyBlackboard->SetValueAsBool("IsInCombat", true);
OnRightClickUp();
}
}
@ -58,7 +63,7 @@ void UHoldToInitCombat::OnRightClickDown()
{
TargetEnemy = RightClickHit;
bRightClickDown = true;
InitCombatWidget->AddToViewport();
//InitCombatWidget->AddToViewport();
}
}
@ -68,7 +73,7 @@ void UHoldToInitCombat::OnRightClickUp()
RightClickDownTime = 0.0f;
if (InitCombatWidget->IsInViewport())
{
InitCombatWidget->RemoveFromViewport();
InitCombatWidget->RemoveFromParent();
}
}
@ -86,10 +91,10 @@ AActor* UHoldToInitCombat::LookingAtEnemy() const
return HitResult.GetActor();
}
if (HitResult.GetActor()->Tags.Contains("Break"))
{
{
HitResult.GetActor()->Destroy();
return nullptr;
}
return nullptr;
}
}
DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f);
return nullptr;