当前位置:网站首页>UE4 第一人称角色模板 添加生命值和调试伤害
UE4 第一人称角色模板 添加生命值和调试伤害
2022-08-05 03:29:00 【Zhichao_97】
效果:

步骤:
1.打开角色蓝图,添加一个变量命名为生命值,变量类型为浮点型变量

2.编译后,设置该变量的默认值为100,表示生命值初始为100

3.在事件图表中添加一个 键盘P 节点,用来调试生命值,每次按下P键,角色的生命值就会减少

4.继续创建如下节点

5.浮点-浮点的值改为10,表示每次生命值减少10点

6.继续创建如下节点,此时已经实现每次按P键 生命值减少10

7.继续创建如下节点,表示:如果生命值《=0时重启关卡

此时已经实现了角色收到伤害的逻辑,接下来要做的是把角色的“血条”显示在屏幕上
8.在内容浏览器中,点击鼠标右键 选择用户界面-》控件蓝图

命名为 生命值_UI

9.双击打开生命值_UI,先拖入一个水平框

10.再拖入一个进度条和文本,要注意层级关系

11.文本的设置如下:

12.进度条的设置如下:

效果:

13.点击 图表
14.添加一个自定义事件 ,命名为更新生命值

15.选中 更新生命值自定义事件,点击 新建参数

参数命名为生命值 浮点

16.创建如下节点,由于进度条的范围是0~1,因此这里将生命值÷100,

17.获取进度条的引用

18.创建如下节点,来将生命值更新到进度条中

接下来希望生命值小于30时变红
19.创建如下节点

20.打开第一人称角色蓝图,在事件开始运行时就创建控件并添加到视口中,

21.右键点击Return Value ,选择提升为变量

22.命名为生命值_UI,这样这个变量可以在收到伤害的事件中调用

23.回到减小生命值的事件逻辑中,将刚提升的变量引入

24.将自定义事件引入

下一篇:
UE4 后期处理体积 (角色受到伤害场景颜色变淡案例)
边栏推荐
- Distributed systems revisited: there will never be a perfect consistency scheme...
- Call Alibaba Cloud oss and sms services
- Use CH341A to program external Flash (W25Q16JV)
- UE4 opens doors with overlapping events
- The pit of std::string::find return value
- 【 genius_platform software platform development 】 : seventy-six vs the preprocessor definitions written cow force!!!!!!!!!!(in the other groups conding personnel told so cow force configuration to can
- [TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
- Talking about data security governance and privacy computing
- The sword refers to Offer--find the repeated numbers in the array (three solutions)
- 【Mysql进阶优化篇02】索引失效的10种情况及原理
猜你喜欢

2022-08-04 The sixth group, hidden from spring, study notes

Use CH341A to program external Flash (W25Q16JV)

测试薪资这么高?刚毕业就20K

Based on holding YOLOv5 custom implementation of FacePose YOLO structure interpretation, YOLO data format conversion, YOLO process modification"

大像素全景制作完成后,推广方式有哪些?

The second council meeting of the Dragon Lizard Community was successfully held!Director general election, 4 special consultants joined
![[Solved] Unity Coroutine coroutine is not executed effectively](/img/ab/035ef004a561fb98d3dd1d7d8b5618.png)
[Solved] Unity Coroutine coroutine is not executed effectively

Details such as compiling pretreatment

2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试

Acid (ACID) Base (BASE) Principles for Database Design
随机推荐
ASP.NET application--Hello World
ffmpeg pixel format basics
[Software testing] unittest framework for automated testing
【已解决】Unity Coroutinue 协程未有效执行的问题
905. 区间选点
leetcode-每日一题1403. 非递增顺序的最小子序列(贪心)
iMedicalLIS监听程序(2)
[Storage] Dawning Storage DS800-G35 ISCSI maps each LUN to the server
Android 面试题——如何徒手写一个非阻塞线程安全队列 ConcurrentLinkedQueue?
Intersection of Boolean Operations in SuperMap iDesktop.Net - Repairing Complex Models with Topological Errors
2022.8.4-----leetcode.1403
GC Gaode coordinate and Baidu coordinate conversion
ffmpeg 像素格式基础知识
新人如何入门和学习软件测试?
Open-Falcon of operation and maintenance monitoring system
STM32 uses stm32cubemx LL library series tutorial
Hard power or soft power, which is more important to testers?
Thinking (88): Use protobuf custom options for multi-version management of data
Ice Scorpion V4.0 attack, security dog products can be fully detected
静态方法获取配置文件数据