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