How to set skins for players 1,2,3,4 specifically?

Hello! I am trying to make a multiplayer co-op game and I ran into an issue. Basically I want Player 1 to have Skin1, Player 2 Skin2, Player 3 Skin3, Player 4 Skin4. I tried with getting the player character or getting the player controller but none of that worked. How could I fix this? I mean for the server it works just fine but for the clients its super buggy. I tried replicating the skins with server and multicast events but I might’ve done something wrong or sum sh*t.

General approach is to overwrite the game modes spawning behavior. By default the GM will automatically spawn a character and possess it with your controller. You can overwrite this behavior and then use On Post Login to spawn and configure the pawn. You’ll have to manually possess the pawn.

The way I handle this is to setup a Faux Pawn as the GM’s default pawn. This Pawn class is bare bones, no movement or anything else. I use this pawn to determine if the level is fully loaded. MMO FPS, large worlds can take a bit of time. Without this the pawn will fall through the map in a multiplayer scenario… world isn’t loaded, no collisions etc.

When the world is loaded on the client I have the pawn call the controller which calls the GM to spawn the character. It spawns the character class and sets a rep_notify var. This var is an ID for skin. The OnRep function then looks it up in a data table and applies it.

1 Like

Well I kinda tried doing something but I am not a big expert in multiplayer games. So here is what i’ve got so far

The system works just fine for the server but for the clients its always the default skin.
What have I done wrong?

Players don’t all join at the same time. If they aren’t on the server when you make your skin change they won’t know about it…ever.

If you’re the first to join who are you multicasting to? When player 2 joins the multicast is to player 1. Yet, player 2 doesn’t get a multicast for your skin.


You need to use Rep Notify variables. Skeletal meshes do not replicate. Besides you do not want to replicate components, meshes etc. Only small data types like float, enum, int, bool struct, etc.

Setup a data table that lists all of your customizations. Create a variable that will hold the ID/ROW. Set that var to rep_notify.

This will create an OnRep_function for the variable. Inside this function apply the cosmetic changes. Get the value from the variable, data table look up, set your change.

On the server side you simply “SET” the rep_notify variable. The onrep function will instantly fire, thus executing the changes on the server.

The replication system will then replicate the variable to all other players. When they get it the on rep function will fire for them.

Tada.

Rep_Notify variables principle purpose is to execute a bound function when it’s value changes.

If you need a vid let me know.

1 Like

Ok so I kinda tried to figure out by my own but I’ve got nothing and I think I need a vid. I understood why it doesn’t work doe

I’ll get to it this evening or tomorrow. :+1:

1 Like

thanks

Hi! I just want to let you know that I haven’t received any video from you.

I got slammed this weekend with work etc. I’ll push it through tomorrow.

1 Like

no problem mate. me too

Vid is uploading, will DM when ready.

thanks! it worked but for some reason when I spawn the player it isnt able to move (I enabled input)

Are you possessing with the controller?
Are you properly creating the mapping context (IMC)?

Debug movement inputs to print string.

Had another thought. If you’re setting IMC in the controller, re-init when you change pawns.

fixed it. I just changed the enhanced input to axis input and now it works perfectly for now. Thank you very much man. Really apreciate that!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.