Updated Combat to Set Camera to Face Enemy
This commit is contained in:
parent
b5048e4be3
commit
d100a85a0d
BIN
Content/Assets/Objects/Tutrorial_Assets/Tutorial_Wood_Texture.uasset
(Stored with Git LFS)
BIN
Content/Assets/Objects/Tutrorial_Assets/Tutorial_Wood_Texture.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/Build.umap
(Stored with Git LFS)
BIN
Content/Levels/Build.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/C2Plane.uasset
(Stored with Git LFS)
BIN
Content/Levels/C2Plane.uasset
(Stored with Git LFS)
Binary file not shown.
@ -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>());
|
||||
|
@ -28,7 +28,6 @@ protected:
|
||||
UFUNCTION()
|
||||
void Sneak();
|
||||
|
||||
|
||||
UCapsuleComponent* PlayerCapsule;
|
||||
|
||||
public:
|
||||
@ -37,15 +36,15 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true"))
|
||||
class UInventoryComponent* Inventory; //Using the InventoryComponent class
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
|
||||
UUserWidget* ItemSelectorWidget;
|
||||
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
|
||||
void KeyPressed();
|
||||
|
||||
|
||||
UPROPERTY(EditAnyWhere)
|
||||
float TraceDistance = 300;
|
||||
|
||||
@ -54,7 +53,7 @@ public:
|
||||
|
||||
UPROPERTY()
|
||||
class UPawnNoiseEmitterComponent* NoiseEmitter;
|
||||
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health")
|
||||
float Health;
|
||||
|
||||
@ -63,7 +62,7 @@ public:
|
||||
|
||||
UPROPERTY(VisibleDefaultsOnly, Category = "LineTrace")
|
||||
bool bHit;
|
||||
|
||||
|
||||
//Using the item in the inventory
|
||||
UFUNCTION(BlueprintCallable, Category= "Items")
|
||||
void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class
|
||||
@ -75,7 +74,7 @@ public:
|
||||
UCameraComponent* ThisCamera;
|
||||
|
||||
FVector OriginalCameraLocation;
|
||||
|
||||
|
||||
FRotator OriginalCameraRotation;
|
||||
|
||||
int OriginalCameraFOV;
|
||||
@ -90,7 +89,7 @@ public:
|
||||
|
||||
APostProcessVolume* PostProcessVolume;
|
||||
|
||||
TArray <AActor*> AIActors;
|
||||
TArray<AActor*> AIActors;
|
||||
|
||||
FName Enemy;
|
||||
|
||||
|
@ -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();
|
||||
@ -72,7 +79,7 @@ void ATurnBaseCombatV2::EndCombat()
|
||||
{
|
||||
StatusEffect->OnExpiry(PlayerActor);
|
||||
}
|
||||
|
||||
|
||||
HUD->RemoveFromParent();
|
||||
APawn* PlayerPawn = Cast<APawn>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
||||
PlayerPawn->bUseControllerRotationYaw = true;
|
||||
@ -217,7 +224,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
OnEnemyTurn.Broadcast(EnemyActor, PlayerActor);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//Ends Combat if either the player or enemy is dead
|
||||
if (*EnemyHealth <= 0)
|
||||
{
|
||||
@ -288,7 +295,7 @@ void ATurnBaseCombatV2::SwitchTurn()
|
||||
//bIsPlayerTurn = !bIsPlayerTurn;
|
||||
TurnIndicatorTextBlock->SetText(FText::FromString("Enemy Turn"));
|
||||
ToggleButtons();
|
||||
|
||||
|
||||
FTimerHandle UnusedHandle;
|
||||
GetWorldTimerManager().SetTimer(UnusedHandle, this, &ATurnBaseCombatV2::EnemyTurn, 2.0f, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user