[박치영] Animation 추가
parent
3a78d0a63f
commit
c222e6295b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -77,6 +77,7 @@ ACombatCharacter::ACombatCharacter()
|
|||
JoggingSpeed = 500.f;
|
||||
SprintSpeed = 700.f;
|
||||
|
||||
ChargeAttackTime = 0.18f;
|
||||
Health = 100.f;
|
||||
PelvisBoneName = TEXT("pelvis");
|
||||
}
|
||||
|
@ -196,7 +197,12 @@ void ACombatCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerIn
|
|||
EnhancedInputComponent->BindAction(ToggleCombatAction, ETriggerEvent::Started, this, &ACombatCharacter::ToggleCombat);
|
||||
|
||||
//LightAttack
|
||||
EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Started, this, &ACombatCharacter::LightAttack);
|
||||
EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Triggered, this, &ACombatCharacter::LightChargeAttack);
|
||||
EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Completed, this, &ACombatCharacter::LightAttack);
|
||||
|
||||
|
||||
//HeavyAttack
|
||||
EnhancedInputComponent->BindAction(HeavyAttackAction, ETriggerEvent::Started, this, &ACombatCharacter::HeavyAttack);
|
||||
|
||||
//Dodge
|
||||
EnhancedInputComponent->BindAction(DodgeAction, ETriggerEvent::Started, this, &ACombatCharacter::Dodge);
|
||||
|
@ -284,6 +290,33 @@ void ACombatCharacter::ToggleCombat(const FInputActionValue& Value)
|
|||
|
||||
void ACombatCharacter::LightAttack(const FInputActionValue& Value)
|
||||
{
|
||||
if (!ResetChargeAttack())
|
||||
return;
|
||||
IsHeavyAttack = false;
|
||||
|
||||
if (StateManagerComponent->GetCurrentState() == ECharacterState::Attacking)
|
||||
CombatComponent->SetIsAttackSaved(true);
|
||||
else
|
||||
AttackEvent();
|
||||
}
|
||||
|
||||
//누르고 있는 시간을 받기 위해서 FInputActionValue가 아니라 FInputActionInstance로 인자값을 받음
|
||||
void ACombatCharacter::LightChargeAttack(const FInputActionInstance& Instance)
|
||||
{
|
||||
AttackHeldTime = Instance.GetElapsedTime();
|
||||
bAttackCharged = (AttackHeldTime >= ChargeAttackTime);
|
||||
if (bAttackCharged)
|
||||
{
|
||||
if (CanPerformAttack())
|
||||
PerformAttack(ECharacterAction::ChargedAttack, CombatComponent->GetAttackCount());
|
||||
}
|
||||
}
|
||||
|
||||
void ACombatCharacter::HeavyAttack(const FInputActionValue& Value)
|
||||
{
|
||||
if (bAttackCharged)
|
||||
return;
|
||||
IsHeavyAttack = true;
|
||||
if (StateManagerComponent->GetCurrentState() == ECharacterState::Attacking)
|
||||
CombatComponent->SetIsAttackSaved(true);
|
||||
else
|
||||
|
@ -495,6 +528,18 @@ void ACombatCharacter::SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode)
|
|||
}
|
||||
}
|
||||
|
||||
bool ACombatCharacter::ResetChargeAttack()
|
||||
{
|
||||
AttackHeldTime = 0.f;
|
||||
if (bAttackCharged)
|
||||
{
|
||||
bAttackCharged = false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void ACombatCharacter::PerformAttack(ECharacterAction attackType, int32 attackIndex)
|
||||
{
|
||||
ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon();
|
||||
|
@ -524,7 +569,7 @@ void ACombatCharacter::PerformAttack(ECharacterAction attackType, int32 attackIn
|
|||
PlayAnimMontage(attackMontage);
|
||||
|
||||
int idx = attackIdx + 1;
|
||||
if (idx > montages.Num())
|
||||
if (idx >= montages.Num())
|
||||
idx = 0;
|
||||
|
||||
CombatComponent->SetAttackCount(idx);
|
||||
|
@ -681,7 +726,8 @@ ECharacterAction ACombatCharacter::GetDesiredAttackType()
|
|||
if (GetMovementSpeedMode() == EMovementSpeedMode::Sprinting)
|
||||
return ECharacterAction::SprintAttack;
|
||||
|
||||
//TODO : Heavy Attack Ãß°¡
|
||||
if (IsHeavyAttack)
|
||||
return ECharacterAction::HeavyAttack;
|
||||
|
||||
return ECharacterAction::LightAttack;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "InputActionValue.h"
|
||||
#include "InputAction.h"
|
||||
#include "Interface/CombatInterface.h"
|
||||
#include "Components/StateManagerComponent.h"
|
||||
#include "Definitions/GameEnums.h"
|
||||
|
@ -51,6 +52,9 @@ class ACombatCharacter : public ACharacter, public ICombatInterface
|
|||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
class UInputAction* LightAttackAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
class UInputAction* HeavyAttackAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
class UInputAction* DodgeAction;
|
||||
|
||||
|
@ -59,6 +63,9 @@ class ACombatCharacter : public ACharacter, public ICombatInterface
|
|||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
class UInputAction* SprintAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
float ChargeAttackTime;
|
||||
public:
|
||||
ACombatCharacter();
|
||||
|
||||
|
@ -100,6 +107,8 @@ protected:
|
|||
void Interact(const FInputActionValue& Value);
|
||||
void ToggleCombat(const FInputActionValue& Value);
|
||||
void LightAttack(const FInputActionValue& Value);
|
||||
void LightChargeAttack(const FInputActionInstance& Instance);
|
||||
void HeavyAttack(const FInputActionValue& Value);
|
||||
void Dodge(const FInputActionValue& Value);
|
||||
void ToggleWalk(const FInputActionValue& Value);
|
||||
void StartSprint(const FInputActionValue& Value);
|
||||
|
@ -119,6 +128,7 @@ private:
|
|||
void EnableRagdoll();
|
||||
void SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode);
|
||||
FORCEINLINE EMovementSpeedMode GetMovementSpeedMode() const { return MovementSpeedMode; }
|
||||
bool ResetChargeAttack();
|
||||
|
||||
private:
|
||||
void PerformAttack(ECharacterAction attackType, int32 attackIndex);
|
||||
|
@ -166,8 +176,13 @@ public:
|
|||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
||||
float SprintSpeed;
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats", meta = (AllowPrivateAccess = "true"))
|
||||
float Health;
|
||||
|
||||
private:
|
||||
bool IsHeavyAttack;
|
||||
float AttackHeldTime;
|
||||
bool bAttackCharged;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue