99 - Elim Animation

This commit is contained in:
Kingsmedia 2022-05-07 19:10:32 +02:00
parent 9999ef2d37
commit 659a9b30de
13 changed files with 55 additions and 19 deletions

Binary file not shown.

Binary file not shown.

View File

@ -38,6 +38,7 @@ void UBlasterAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
bAiming = BlasterCharacter->IsAiming(); bAiming = BlasterCharacter->IsAiming();
TurningInPlace = BlasterCharacter->GetTurningInPlace(); TurningInPlace = BlasterCharacter->GetTurningInPlace();
bRotateRootBone = BlasterCharacter->ShouldRotateRootBone(); bRotateRootBone = BlasterCharacter->ShouldRotateRootBone();
bEliminated = BlasterCharacter->IsEliminated();
// Offset Yaw for Strafing // Offset Yaw for Strafing
FRotator AimRotation = BlasterCharacter->GetBaseAimRotation(); FRotator AimRotation = BlasterCharacter->GetBaseAimRotation();
FRotator MovementRotation = UKismetMathLibrary::MakeRotFromX(BlasterCharacter->GetVelocity()); FRotator MovementRotation = UKismetMathLibrary::MakeRotFromX(BlasterCharacter->GetVelocity());

View File

@ -75,4 +75,7 @@ private:
UPROPERTY(BlueprintReadOnly, Category="Movement", meta=(AllowPrivateAccess = "true")) UPROPERTY(BlueprintReadOnly, Category="Movement", meta=(AllowPrivateAccess = "true"))
bool bRotateRootBone; bool bRotateRootBone;
UPROPERTY(BlueprintReadOnly, Category="Movement", meta=(AllowPrivateAccess = "true"))
bool bEliminated;
}; };

View File

@ -100,9 +100,20 @@ void ABlasterCharacter::PlayFireMontage(bool bAiming)
} }
} }
void ABlasterCharacter::Eliminated() void ABlasterCharacter::PlayEliminatedMontage()
{ {
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (AnimInstance && EliminatedMontage)
{
UE_LOG(LogTemp, Warning, TEXT("Playing Eliminated Montage, %s"), (bEliminated ? "true" : "false"));
AnimInstance->Montage_Play(EliminatedMontage);
}
}
void ABlasterCharacter::Eliminated_Implementation()
{
bEliminated = true;
PlayEliminatedMontage();
} }
void ABlasterCharacter::PlayHitReactMontage() void ABlasterCharacter::PlayHitReactMontage()
@ -124,7 +135,10 @@ void ABlasterCharacter::ReceiveDamage(AActor* DamagedActor, float Damage, const
Health = FMath::Clamp(Health - Damage, 0.f, MaxHealth); Health = FMath::Clamp(Health - Damage, 0.f, MaxHealth);
UpdateHUDHealth(); UpdateHUDHealth();
if (Health > 0.f)
{
PlayHitReactMontage(); PlayHitReactMontage();
}
if (Health == 0.f) if (Health == 0.f)
{ {
@ -388,18 +402,18 @@ void ABlasterCharacter::TurnInPlace(float DeltaTime)
StartingAimRotation = FRotator(0.f, GetBaseAimRotation().Yaw, 0.f); StartingAimRotation = FRotator(0.f, GetBaseAimRotation().Yaw, 0.f);
} }
} }
switch (TurningInPlace) // switch (TurningInPlace)
{ // {
case ETurningInPlace::ETIP_Left: // case ETurningInPlace::ETIP_Left:
UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Left")); // UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Left"));
break; // break;
case ETurningInPlace::ETIP_Right: // case ETurningInPlace::ETIP_Right:
UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Right")); // UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Right"));
break; // break;
case ETurningInPlace::ETIP_NotTurning: // case ETurningInPlace::ETIP_NotTurning:
UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: NotTurning")); // UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: NotTurning"));
break; // break;
} // }
} }
void ABlasterCharacter::HideCameraIfCharacterClose() void ABlasterCharacter::HideCameraIfCharacterClose()
@ -433,7 +447,10 @@ float ABlasterCharacter::CalculateSpeed()
void ABlasterCharacter::OnRep_Health() void ABlasterCharacter::OnRep_Health()
{ {
UpdateHUDHealth(); UpdateHUDHealth();
if (Health > 0.f)
{
PlayHitReactMontage(); PlayHitReactMontage();
}
} }
void ABlasterCharacter::UpdateHUDHealth() void ABlasterCharacter::UpdateHUDHealth()

View File

@ -21,6 +21,9 @@ public:
virtual void PostInitializeComponents() override; virtual void PostInitializeComponents() override;
virtual void OnRep_ReplicatedMovement() override; virtual void OnRep_ReplicatedMovement() override;
void PlayFireMontage(bool bAiming); void PlayFireMontage(bool bAiming);
void PlayEliminatedMontage();
UFUNCTION(NetMulticast, Reliable)
void Eliminated(); void Eliminated();
protected: protected:
@ -82,6 +85,9 @@ private:
UPROPERTY(EditAnywhere, Category = Combat) UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* HitReactMontage; class UAnimMontage* HitReactMontage;
UPROPERTY(EditAnywhere, Category = Combat)
class UAnimMontage* EliminatedMontage;
void HideCameraIfCharacterClose(); void HideCameraIfCharacterClose();
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
@ -108,6 +114,8 @@ private:
class ABlasterPlayerController* BlasterPlayerController; class ABlasterPlayerController* BlasterPlayerController;
bool bEliminated = false;
public: public:
void SetOverlappingWeapon(AWeapon* Weapon); void SetOverlappingWeapon(AWeapon* Weapon);
bool IsWeaponEquipped(); bool IsWeaponEquipped();
@ -119,4 +127,5 @@ public:
FVector GetHitTarget() const; FVector GetHitTarget() const;
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; } FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; } FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; }
FORCEINLINE bool IsEliminated() const { return bEliminated; }
}; };

View File

@ -3,8 +3,14 @@
#include "BlasterGameMode.h" #include "BlasterGameMode.h"
void ABlasterGameMode::PlayerEliminated(ABlasterCharacter* ElimmedCharacter, ABlasterPlayerController* VictimController, #include "Blaster/Character/BlasterCharacter.h"
void ABlasterGameMode::PlayerEliminated(ABlasterCharacter* EliminatedCharacter, ABlasterPlayerController* VictimController,
ABlasterPlayerController* AttackerController) ABlasterPlayerController* AttackerController)
{ {
if (EliminatedCharacter)
{
EliminatedCharacter->Eliminated();
}
} }

View File

@ -16,5 +16,5 @@ class BLASTER_API ABlasterGameMode : public AGameMode
public: public:
virtual void PlayerEliminated(class ABlasterCharacter* ElimmedCharacter, class ABlasterPlayerController* VictimController, class ABlasterPlayerController* AttackerController); virtual void PlayerEliminated(class ABlasterCharacter* EliminatedCharacter, class ABlasterPlayerController* VictimController, class ABlasterPlayerController* AttackerController);
}; };