【UE5 多人联机教程】05-更改角色颜色

效果

步骤

  1. 打开"BP_ThirdPersonCharacter",找到角色的材质

创建材质实例

  1. 在"BP_ThirdPersonCharacter"中新建一个整型变量,命名为"PlayerColorIndex"

勾选可编辑实例、生成时公开,复制选择"RepNotify"

复制选择"RepNotify"后,会自动创建一个函数"OnRep_PlayerColorIndex",当变量"PlayerColorIndex"发生变化时就会执行这个函数

打开函数"OnRep_PlayerColorIndex",添加如下节点,当索引值发生变化时修改材质实例的参数

在事件图表中添加一个自定义事件,命名为"EVE_Set_PlayerColorIndex",该事件有一个整型输入参数,命名为"PlayerColorIndex",,复制选择"在服务器上运行",勾选可靠函数。

该事件执行时,就将输入的参数"PlayerColorIndex"赋值给变量"PlayerColorIndex"

  1. 打开"UMG_Lobby",添加控件的切换事件

当切换控件选项时,将控件选项的索引赋值给蓝图"BP_ThirdPersonCharacter"中的函数"EVE_PlayerColorIndex"的参数"PlayerColorIndex"

相关推荐
zhangzhangkeji1 小时前
UE5 C++(71):文件是否存在,文件夹是否存在,FPaths :: FileExists( const FString & InPath) ;
ue5
妙为2 小时前
UE5角色穿过石头穿模
ue5·unreal engine5·角色穿越石头·穿模
技术策划Boring1 天前
2025年工作复盘:开放世界3A项目配置管线与性能监控的探索
游戏·ue5·虚幻·p4·perforce
zhangzhangkeji3 天前
UE5 C++(70-2):定义成员函数 getCleanDirectory(..) 和枚举类 EFileDirectoryType,来获得目录
ue5
avi91114 天前
UE4-UE5虚幻引擎-前置学习三,优化,基础CPP
ue5·ue4·游戏开发·虚幻·游戏优化·游戏代码
zhangzhangkeji4 天前
UE5线程进阶(3-2):任务图的相关源码整理。 FGraphEvent 与 TGraphTask 的区别和联系
ue5
zhangzhangkeji6 天前
UE5线程进阶(3-1):
ue5
zhangzhangkeji6 天前
UE5线程进阶(2-3):enum ENamedThreads命名空间 :: Type : int32 { RHIThread = 0 } 是渲染硬件接口线程
ue5
zhangzhangkeji7 天前
UE5线程进阶(2-1):枚举类EAsyncExecution,作业类TAsyncRunnable、TAsyncQueuedWork,及全局线程函数 Async(..),及线程调用的 4 种方法总结
ue5
zhangzhangkeji8 天前
UE5线程进阶(1):
ue5