iT邦幫忙

2025 iThome 鐵人賽

DAY 17
0

今天要幫敵人增加 血條 UI !
那因為 UI 沒有那麼吃資源我這邊就直接用 Blueprint 了。

1. 首先新增 Widget Blueprint

-> 右鍵新增
https://ithelp.ithome.com.tw/upload/images/20251001/20171036dxczXGv003.png
選擇 User Widget
https://ithelp.ithome.com.tw/upload/images/20251001/20171036arwh3SWrmD.png

2. UI 設定

在左邊面板拉下 CanvasProgress Bar (我這裡命名成 HealthBar)
https://ithelp.ithome.com.tw/upload/images/20251001/20171036MBGwlSf5Z8.png
Progress bar 的設定是這樣 (確定上方的 Is Visible 是打勾的)
https://ithelp.ithome.com.tw/upload/images/20251001/20171036q3o6qHVLUe.png

3. 敵人 Actor 設定

在敵人 Actor 裡新增 Widget
https://ithelp.ithome.com.tw/upload/images/20251001/20171036HFln9lW73T.png
在 User Iterface 裡的 Widget Class 設為剛剛建立的 Widget Blueprint (WB_EnemyUI)
https://ithelp.ithome.com.tw/upload/images/20251001/20171036TiWJXb5yFw.png
然後調整 UI 高度
https://ithelp.ithome.com.tw/upload/images/20251001/20171036At7aPm30Y2.png
再來在藍圖裡這樣接,將 HealthComponent 的 Current Health 與 Max Health 相除再設為 Progress Bar
的 Percentage,最後還有使UI面向玩家相機。
https://ithelp.ithome.com.tw/upload/images/20251001/20171036WziA8ef9nn.png

就完成拉!!


上一篇
# Day 16|鐵人賽前半段回顧
下一篇
# Day 18|敵人 AI (一)
系列文
30 天用 Unreal Engine 5 C++ 開發遊戲21
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言