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

View File

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

View File

@ -36,7 +36,6 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
EnemyBlackboard->SetValueAsBool("IsInCombat", true); EnemyBlackboard->SetValueAsBool("IsInCombat", true);
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health")); FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy); int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
EnemyHealth = EnemyHealthPtr; EnemyHealth = EnemyHealthPtr;
if (HUD->IsInViewport()) return; if (HUD->IsInViewport()) return;
@ -58,6 +57,14 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
PlayerController->SetInputMode(FInputModeUIOnly()); PlayerController->SetInputMode(FInputModeUIOnly());
PlayerController->bShowMouseCursor = true; 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 = ""; CurrentComboString = "";
UpdateComboString(CurrentComboString); UpdateComboString(CurrentComboString);
RevertActionPoints(); RevertActionPoints();