Unreal - 딜레이 프로그래스바

2025. 6. 7. 07:26·Unreal5 프로젝트 다이어리

철권처럼 프로그래스바가 그냥 줄어든게 아니고 데미지가 단 만큼

딜레이프로그래스바를 넣어 만들보겠습니다

 

오버레이를 둔뒤

AI의 HP를 나타내는 프로그래스바(흰색)을 앞으로 

딜레이프로그래스바(빨간색)를 뒤로 하이어라키 세팅한뒤

AI HP프로그래스바의 배경을 투명하게합니다

 

Tick을 사용하여 프로그래스바를 lerp움직임으로 만들어도되나

최적화를 위해 타이머로 프로그래스바를 움직이겠습니다

 

FTimerHandle th_DelayBar;
float targetDelayBarPercent = 1.0;

UFUNCTION()
void UpdateDelayBar();

 

위젯의 NativeConstruct에서 타이머를 설정합니다

void USkeletonHPBarWidget::NativeConstruct()
{
    Super::NativeConstruct();
    if (GetWorld())
    {
        GetWorld()->GetTimerManager().SetTimer(th_DelayBar, this, &USkeletonHPBarWidget::UpdateDelayBar, 0.016f, true);
    }
    if (IsValid(pb_healthBar_DelayBar))
    {
        pb_healthBar_DelayBar->SetPercent(1.0f); 
    }
    targetDelayBarPercent = 1.0f;
}

 

딜레이프로그래스바를 FInterpTo로 선형보간하며 업데이트합니다

Tick에서 한틱당 0.166초 정도하니 0.016, 그리고 업데이트속도 1.5초로 설정했습니다

void USkeletonHPBarWidget::UpdateDelayBar()
{
    float currentDelayPercent = pb_healthBar_DelayBar->GetPercent();
    if (currentDelayPercent > targetDelayBarPercent)
    {
        float newLerpPercent = FMath::FInterpTo(currentDelayPercent, targetDelayBarPercent, 0.016f, 1.5f);
        pb_healthBar_DelayBar->SetPercent(newLerpPercent);
    }
    else
    {
        pb_healthBar_DelayBar->SetPercent(targetDelayBarPercent);
    }
}

 

프로그래스바 업데이트해주는 함수에 딜레이 프로그래스바가 목표로 해야 하는 현재 HP 비율 값을 갱신하기위해 넣어줍니다

void USkeletonHPBarWidget::updateHpBar(float currentHp, float maxHp)
{
	targetDelayBarPercent = barPercent;
}

회복했을때의 가정도 해주겠습니다

반대의 경우도 세팅해줍니다

void USkeletonHPBarWidget::UpdateDelayBar()
{
    float currentDelayPercent = pb_healthBar_DelayBar->GetPercent();
    if (currentDelayPercent > targetDelayBarPercent)
    {
        float newLerpPercent = FMath::FInterpTo(currentDelayPercent, targetDelayBarPercent, 0.016f, 2.0f);
        pb_healthBar_DelayBar->SetPercent(newLerpPercent);
    }
    else if (currentDelayPercent < targetDelayBarPercent)
    {
        float newLerpPercent = FMath::FInterpTo(currentDelayPercent, targetDelayBarPercent, 0.016f, 4.0f);
        pb_healthBar_DelayBar->SetPercent(newLerpPercent);
    }
    else
    {
        pb_healthBar_DelayBar->SetPercent(targetDelayBarPercent);
    }
}

 

 

이제 해당 updateHPBar함수가 호출이되면 딜레이프로그래스바가 연출됩니다

딜레이프로그래스바 색을 흰색으로 바꾸겠습니다

 

 

플레이어의 hp바도 똑같이 적용해주었습니다

 

 

 

 

몹수가많으면 이런느낌입니다

 

 

 

 

'Unreal5 프로젝트 다이어리' 카테고리의 다른 글

Unreal - 드래곤 캐릭터 만들기 (1)  (0) 2025.06.12
Unreal - 데미지 오버레이 만들기  (0) 2025.06.08
Unreal - 일시정지 위젯 만들기  (0) 2025.06.07
Unreal - 위젯 나이아가라  (0) 2025.06.06
Unreal - Foot Step Sound  (0) 2025.05.30
'Unreal5 프로젝트 다이어리' 카테고리의 다른 글
  • Unreal - 드래곤 캐릭터 만들기 (1)
  • Unreal - 데미지 오버레이 만들기
  • Unreal - 일시정지 위젯 만들기
  • Unreal - 위젯 나이아가라
lucodev
lucodev
커피와 노트북 그리고 개발
  • lucodev
    루코 개발테이블
    lucodev
  • 전체
    오늘
    어제
    • 분류 전체보기 (123) N
      • Unreal5 프로젝트 다이어리 (73)
      • Unreal5 프로젝트 다이어리2 (5) N
      • Unreal 팁 (8)
      • Unreal 디버깅 (8)
      • C++ 프로그래머스 다이어리 (21)
        • Stack (3)
        • Hash (4)
        • Heap (2)
        • Sort (1)
      • 코드 개인보관함 (8) N
  • 인기 글

  • 최근 글

  • 최근 댓글

  • 링크

  • 공지사항

  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 태그

    언리얼 foot step
    언리얼 모션매칭
    언리얼 로딩
    unreal 모션매칭
    언리얼 컷씬
    unreal loading
    언리얼
    언리얼 로딩창
    언리얼 behaviortree
    unreal 시퀀스
    언리얼 시퀀스
    unreal sequence
    언리얼 look at
    unreal 컷씬
    언리얼 페이드 아웃
    언리얼 behavior tree
    unreal look at
    언리얼 motionmatching
    언리얼 비헤이비어트리
    unreal 로딩
  • hELLO· Designed By정상우.v4.10.3
lucodev
Unreal - 딜레이 프로그래스바
상단으로

티스토리툴바