Updated Combat to Set Camera to Face Enemy

This commit is contained in:
Philip W 2023-03-06 04:28:13 +00:00
parent b5048e4be3
commit d100a85a0d
6 changed files with 26 additions and 20 deletions

Binary file not shown.

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

Binary file not shown.

BIN
Content/Levels/C2Plane.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -122,7 +122,7 @@ void ATempCharacter::KeyPressed()
// Line trace logic
void ATempCharacter::LineTraceLogic()
{
UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated"));
//UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated"));
float GlobalTrace = TraceDistance;
FHitResult OutHit;
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());

View File

@ -28,7 +28,6 @@ protected:
UFUNCTION()
void Sneak();
UCapsuleComponent* PlayerCapsule;
public:

View File

@ -36,7 +36,6 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
EnemyHealth = EnemyHealthPtr;
if (HUD->IsInViewport()) return;
@ -58,6 +57,14 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
PlayerController->SetInputMode(FInputModeUIOnly());
PlayerController->bShowMouseCursor = true;
FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
Direction.Normalize();
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
LookAtRotation.Pitch = -9.0f;
PlayerController->SetControlRotation(LookAtRotation);
//DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10);
CurrentComboString = "";
UpdateComboString(CurrentComboString);
RevertActionPoints();