히든 승리 조건이 춤 15회인데, E키를 5번만 눌러도 히든 승리 위젯이 나옴...
증상 :
E 한 번 누를 때마다 DanceCount가 2씩 증가하고 있었음
3 → 4 → 6 → 8 → 10 → 12 → 22EnhancedInput->BindAction(DanceAction, ETriggerEvent::Triggered, this, &ADCCharacter::Dance);
EnhancedInput->BindAction(AttackAction, ETriggerEvent::Triggered, this, &ADCCharacter::Attack);
문제점 :
| 이벤트 타입 | 호출 시점 | 사용 사례 |
|---|---|---|
| Started | 키를 누르는 순간 1번만 호출 | 단발성 액션 (점프, 공격, 춤) |
| Triggered | 키를 누르고 있는 동안 매 프레임 호출 | 연속 입력 (이동, 카메라 회전) |
| Completed | 키를 떼는 순간 1번만 호출 | 입력 종료 감지 |
void ADCCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
if (UEnhancedInputComponent* EnhancedInput = Cast<UEnhancedInputComponent>(PlayerInputComponent))
{
// 연속 입력이 필요한 액션
EnhancedInput->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ADCCharacter::Move);
EnhancedInput->BindAction(LookAction, ETriggerEvent::Triggered, this, &ADCCharacter::Look);
// 단발성 액션 - Started로 변경
EnhancedInput->BindAction(DanceAction, ETriggerEvent::Started, this, &ADCCharacter::Dance);
EnhancedInput->BindAction(AttackAction, ETriggerEvent::Started, this, &ADCCharacter::Attack);
EnhancedInput->BindAction(JumpAction, ETriggerEvent::Started, this, &ADCCharacter::HandleJumpTriggered);
}
}
Enhanced Input System에서 단발성 액션은 반드시 ETriggerEvent::Started 사용
연속 입력이 필요한 경우만 ETriggerEvent::Triggered 사용
입력 바인딩 시 이벤트 타입 선택이 게임 로직에 직접적인 영향을 미침