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

效果 

 

步骤

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

 

 创建材质实例

 2. 在“BP_ThirdPersonCharacter”中新建一个整型变量,命名为“PlayerColorIndex”

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

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

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

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

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

 3. 打开“UMG_Lobby”,添加控件的切换事件

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

猜你喜欢

转载自blog.csdn.net/ChaoChao66666/article/details/131946781