Unreal - Material Parameter Collection 사용하기

2025. 6. 21. 15:03·Unreal5 프로젝트 다이어리

 

드래곤으로 변신하기위한 프로그래스바 게이지를 만들어줍니다

2025.06.20 - [Unreal 팁] - Unreal - 원형 프로그래스바 반원으로 바꾸기

 

 

Unreal - 원형 프로그래스바 반원으로 바꾸기

2025.04.24 - [Unreal5 프로젝트 다이어리] - Unreal - 원형 프로그래스바(ProgressBar) 만들기 Unreal - 원형 프로그래스바(ProgressBar) 만들기스택형 스킬의 UI를 최종 수정하기전 스택차징이된걸 시각적으로 표

lucodev.tistory.com

 

반원의 프로그래스바를 만들어줍니다

 

 

해당칸은 총 14칸입니다

 

해당 반원 프로그래스바를 인게임에서 값을 변경하기위해 MaterialParameterCollection을 사용해줍니다

 

사용할 MaterialParameterCollection을  위젯에 Property에 할당

그리고 해당 progressbar의 값을 변경하기위한 함수 SetSoulCollectionBar함수를 선언

UPROPERTY(EditAnywhere, Category = "MPC")
UMaterialParameterCollection* soulParameterCollection;

UMaterialParameterCollectionInstance* soulCollectionInstance;

UFUNCTION()
void SetSoulCollectionBar(float gaze);

 

위젯에서 할당해줍니다

 

메테리얼 파라미터 컬렉션에서 인덱스0을 Progress로 설정

 

SetSoulCollectionBar함수입니다

14칸을 기준으로 float 가변인자값으로 게이지를 바꾸는 함수를 만들어줍니다

void USwordCharacterWidget::SetSoulCollectionBar(float gaze)
{
	if (!soulCollectionInstance)
	{
		soulCollectionInstance = GetWorld()->GetParameterCollectionInstance(soulParameterCollection);
		if (!soulCollectionInstance) return;
	}
	float totalSteps = 14;
	float clampedGaze = FMath::Clamp(gaze, 0, totalSteps); // 0 ~ 14
	soulProgress = clampedGaze / 14.f;
	soulCollectionInstance->SetScalarParameterValue(FName("Progress"), soulProgress);
}

 

 

0.5씩 게이지가 증가하도록 하는 함수를 만들어줍니다

또한 clamp로 제 0 ~ 14값으로 제한합니다

UFUNCTION()
void IncreaseSoulCollectionBar();

float currentSoulGaze = 0;

 

void USwordCharacterWidget::IncreaseSoulCollectionBar()
{
	currentSoulGaze = FMath::Clamp(currentSoulGaze + 0.5, 0, 14);
	SetSoulCollectionBar(currentSoulGaze);
}

 

 

적을 죽이면 영혼이 드랍됩니다 영혼을 먹으면 IncreaseSoulCollectionBar함수를 호출하여 게이지를 0.5를 증가시켜줍니다

(호출하는예시)

 

APlayerController* playerCon;
playerCon = Cast<APlayerController>(UGameplayStatics::GetPlayerController(GetWorld(), 0));
ASwordCharacter* swordChar = Cast<ASwordCharacter>(playerCon->GetPawn());
swordChar->characterWidget->IncreaseSoulCollectionBar();

 

 

영혼액터를 UI 이미지 2D로 연출을 할려고하지만

위젯에서 이미지는 Emissive값을 전부무시해버리고 강제로 넣어도 이상해집니다

이미지를 기반으로 메테리얼을 만들어줍니다

 

 

UI위젯에서의 결과물

 

 

영혼 한개당 0.5 즉 두개를 먹으면 한칸이 차는걸 볼수있습니다

 

 

 

 

 

 

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

Unreal - LandScape 발소리  (0) 2025.06.26
Unreal - BGM, 사운드 관리법  (0) 2025.06.21
Unreal - 드래곤 캐릭터 만들기(2)  (3) 2025.06.14
Unreal - 드래곤 캐릭터 만들기 (1)  (0) 2025.06.12
Unreal - 데미지 오버레이 만들기  (0) 2025.06.08
'Unreal5 프로젝트 다이어리' 카테고리의 다른 글
  • Unreal - LandScape 발소리
  • Unreal - BGM, 사운드 관리법
  • Unreal - 드래곤 캐릭터 만들기(2)
  • Unreal - 드래곤 캐릭터 만들기 (1)
lucodev
lucodev
커피와 노트북 그리고 개발
  • lucodev
    루코 개발테이블
    lucodev
  • 전체
    오늘
    어제
    • 분류 전체보기 (127) N
      • Unreal5 프로젝트 다이어리 (73)
      • Unreal5 프로젝트 다이어리2 (6) N
      • Unreal 팁 (8)
      • Unreal 디버깅 (8)
      • C++ 프로그래머스 다이어리 (24) N
        • Stack (3)
        • Hash (4)
        • Heap (2)
        • Sort (4) N
        • Exhaustive search (0)
      • 코드 개인보관함 (8)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • 링크

  • 공지사항

  • 블로그 메뉴

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

    unreal look at
    언리얼 look at
    unreal 모션매칭
    unreal 로딩
    언리얼 behaviortree
    언리얼 로딩
    언리얼 컷씬
    언리얼 로딩창
    언리얼 foot step
    언리얼 모션매칭
    unreal loading
    unreal sequence
    언리얼 behavior tree
    언리얼 시퀀스
    언리얼 비헤이비어트리
    언리얼
    unreal 시퀀스
    unreal 컷씬
    언리얼 motionmatching
    언리얼 페이드 아웃
  • hELLO· Designed By정상우.v4.10.3
lucodev
Unreal - Material Parameter Collection 사용하기
상단으로

티스토리툴바