Why doesn't my material change render on different clients?

Hi, i am fairly new to unreal and i am making a multiplayer game. In my game’s lobbies, i want to have a box where you can change the color of the character’s body and put on a hat like in among us. I made the code in blueprint(i don’t know C++ yet) and the player can see himself as a different color when they look down but the other players can’t. can someone help me?

You need to look up replication for this.

Quick & Easy Multiplayer Replication in UE5 Unreal Engine (youtube.com)

Thanks so much! does anyone know how i could do hats? would it be with a socket or something?

Yes, you have to spawn mesh component from server(host) side and attach it to a socket.

All Replication must happen on the server first. The server will replicate the changes down to all other clients.

For cosmetics you should be using a Repnotify setup.

Thanks so much! I had one more thing, I started using variables so the player can change their look in the main menu and the lobby. This does not work and I can’t understand how to fix it!

Create a Struct for the cosmetics. Have an element for each aspect of the cosmetics you wish to modify. Keep the data types as simple as possible (float, int, string, name etc). You can use a data table for look ups. For example If I want specific Materials applied, then I’d use a Name type in the struct. Then use that Name as row name on a data table.

image

Data Table example

Set the Struct as a RepNotify. This will auto create an OnRep function.

Use the OnRep function to make the changes.

image


Implementation

Create a function or event to set a local dummy struct of your modifications. Then pass that struct to the server via RPC.

Servers RPC event will simply Set the RepNotify variable using the dummy struct values.

As Soon as the server sets the variable it gets replicated out. It also triggers the onrep function.

When clients get the updated variable it’ll trigger the onrep function on their end. Thus cosmetics get changed for each player.

This also works for later joiners and reconnects.