(1)FairyGUI 创建血条控件
(2) //角色血条
UGComponent* m_pCharHp; .h文件声明变量
(3)
UWorld* kWorld = GetWorld();
m_pCharHp = UUIPackage::CreateObject(TEXT("FightGame"), TEXT("charHp"), (UObject*)kWorld)->As<UGComponent>();
if (m_pCharHp != nullptr)
{
m_pCharHp->SetParentToRoot();
m_pCharHp->MakeFullScreen(true);
UGObject* CharHpWin = m_pCharHp->GetChild("CharHp");
float modelWidth = GetCapsuleComponent()->GetUnscaledCapsuleRadius()/50.0f * 160.0f;
CharHpWin->SetWidth(modelWidth);
}
(4)设置位置
UWorld* kWorld = GetWorld();
FConstPlayerControllerIterator playerIterator = kWorld->GetPlayerControllerIterator();
FVector2D sreenPos;
tempCurrentPos.Z = tempCurrentPos.Z + 150.0f;
UGameplayStatics::ProjectWorldToScreen(playerIterator->Ge

本文介绍如何使用FairyGUI在游戏开发中创建角色血条控件,并详细解释了血条的位置设置方法及注意事项。通过UGComponent进行血条实例化,并调整其宽度和位置以匹配角色状态。
最低0.47元/天 解锁文章
1160

被折叠的 条评论
为什么被折叠?



