当前位置:网站首页>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 后期处理体积 (角色受到伤害场景颜色变淡案例)
边栏推荐
- ffmpeg 像素格式基础知识
- Kubernetes 网络入门
- ffmpeg -sources分析
- High Item 02 Information System Project Management Fundamentals
- 十五. 实战——mysql建库建表 字符集 和 排序规则
- Web3.0 Dapps - the road to the future financial world
- ffmpeg enumeration decoders, encoders analysis
- Growth-based checkerboard corner detection method
- 静态方法获取配置文件数据
- 高项 02 信息系统项目管理基础
猜你喜欢

告白数字化转型时代,时速云镌刻价值新起点

Bubble Sort and Quick Sort

Talking about data security governance and privacy computing

YYGH-13-Customer Service Center

21 Days Learning Challenge (2) Use of Graphical Device Trees

Walter talked little knowledge | "remote passthrough" that something

Details such as compiling pretreatment

Web3.0 Dapps - the road to the future financial world

Kubernetes 网络入门

leetcode-每日一题1403. 非递增顺序的最小子序列(贪心)
随机推荐
[Solved] Unity Coroutine coroutine is not executed effectively
Initial solution of the structure
【 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
From "useable" to "easy to use", domestic software is self-controllable and continues to advance
Cybersecurity and the Metaverse: Identifying Weak Links
rpc-remote procedure call demo
.NET Application -- Helloworld (C#)
引领数字医学高地,中山医院探索打造未来医院“新范式”
银行数据采集,数据补录与指标管理3大问题如何解决?
Beyond YOLO5-Face | YOLO-FaceV2 officially open source Trick+ academic point full
Dameng 8 database export and import
Redis key基本命令
[TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
Why did they choose to fall in love with AI?
Why is the pca component not associated
【Mysql进阶优化篇02】索引失效的10种情况及原理
剑指Offer--找出数组中重复的数字(三种解法)
Package zip is not available, but is referred to by another package.
IJCAI2022 | DictBert: Pre-trained Language Models with Contrastive Learning for Dictionary Description Knowledge Augmentation
Turn: Charles Handy: Who you are is more important than what you do