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();
TurningInPlace = BlasterCharacter->GetTurningInPlace();
bRotateRootBone = BlasterCharacter->ShouldRotateRootBone();
bEliminated = BlasterCharacter->IsEliminated();
// Offset Yaw for Strafing
FRotator AimRotation = BlasterCharacter->GetBaseAimRotation();
FRotator MovementRotation = UKismetMathLibrary::MakeRotFromX(BlasterCharacter->GetVelocity());

View File

@ -75,4 +75,7 @@ private:
UPROPERTY(BlueprintReadOnly, Category="Movement", meta=(AllowPrivateAccess = "true"))
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()
@ -124,7 +135,10 @@ void ABlasterCharacter::ReceiveDamage(AActor* DamagedActor, float Damage, const
Health = FMath::Clamp(Health - Damage, 0.f, MaxHealth);
UpdateHUDHealth();
PlayHitReactMontage();
if (Health > 0.f)
{
PlayHitReactMontage();
}
if (Health == 0.f)
{
@ -388,18 +402,18 @@ void ABlasterCharacter::TurnInPlace(float DeltaTime)
StartingAimRotation = FRotator(0.f, GetBaseAimRotation().Yaw, 0.f);
}
}
switch (TurningInPlace)
{
case ETurningInPlace::ETIP_Left:
UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Left"));
break;
case ETurningInPlace::ETIP_Right:
UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Right"));
break;
case ETurningInPlace::ETIP_NotTurning:
UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: NotTurning"));
break;
}
// switch (TurningInPlace)
// {
// case ETurningInPlace::ETIP_Left:
// UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Left"));
// break;
// case ETurningInPlace::ETIP_Right:
// UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: Right"));
// break;
// case ETurningInPlace::ETIP_NotTurning:
// UE_LOG(LogTemp, Warning, TEXT("TurningInPlace: NotTurning"));
// break;
// }
}
void ABlasterCharacter::HideCameraIfCharacterClose()
@ -433,7 +447,10 @@ float ABlasterCharacter::CalculateSpeed()
void ABlasterCharacter::OnRep_Health()
{
UpdateHUDHealth();
PlayHitReactMontage();
if (Health > 0.f)
{
PlayHitReactMontage();
}
}
void ABlasterCharacter::UpdateHUDHealth()

View File

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

View File

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

View File

@ -16,5 +16,5 @@ class BLASTER_API ABlasterGameMode : public AGameMode
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);
};