Ok, So I’m trying to set up a basic Character Selection. The issue is I cant Get the clients to see any of the changes, I’ve tried multiple things including:
-From Character Blueprint:
-setting the Mesh (Run on server - Server Sets its Mesh, and The characters and can see both, Client Can see their correct mesh but not other clients or the server)
(Multicast -Server sets its Mesh and the characters mesh, but now neither server nor clients can see each others updated mesh)
(Run On Owning Client - Same result as Multi Cast)
I’ve tried calling it from the game mode, from the player controller, but nothing I seem to do makes any difference, Currently I’ve got it running from the player controller as run on server right after enabling client input, I just need to figure out how to pass the mesh information for other clients and the server to the the clients so they can all see the correct character mesh instead of the default UE mannequin.
Any help on this issue would be greatly appreciated Im sure its something simple but its stopping me dead in my tracks and I need to get passed this.
Use server call to tell the server about owner client’s choice. Then propagate to everyone using Multicast.
The mesh is more of a state change rather than an “event” per se, so prefer using replicated variable for propagating it to clients (this will handle clients joining late). Use RepNotify mode so you get an automatic event whenever the variable is updated.
That Worked! Well at least in so far as all the clients see the correct meshes and so does the server thank you!
Now, since I havent implemented the code to swap character meshes yet theyre all pulling from a default variable so theyre all showing the same character, so now I need to knock up a character selection system and pass the selected mesh through to this variable to test it properly, but thank you! Works perfectly now!
It is indeed very important to use replicated variables for this rather than Multicast.
Not only when players join late but also players that are not nearby or for any other reason are not relevant for sending the RPC at the time will never receive it.
Sometimes you do want this behavior though like when playing a sound event or particle effect so then you would indeed use an RPC rather than replicated variables.
So let me pick your brain for a moment if you would be so kind, Im flying solo as a Dev and so rarely have someone to bounce Ideas off.
I’m attempting to add driveable vehicles to my game, now I have them working for the server, gets in, drives, gets out and gets repossessed and can move around and continue as normal. Now the client, can enter the vehicle, drive around and exit, when exiting the pawn seems to repossess (the camera goes to the right place at least) but I lose all control, even including the ability to open menus so my suspiscion is the pawns getting possessed but the player controller might not be, I’m handling possession and repossession through the vehicle itself (it logs the character and controller driving it, and when an exit request is issued it connects the controller up with the character and repossesses them. This is done as run on server.
My question is this, should I be handling the posession as a local event for just the possessing player (since vehicle movement is already replicated) and simply have a repnotify bool on the car itself that gets set to true when someones in it preventing anyone else possessing it while its occupied (I’ll worry about passengers later).
But is that the kinda situation repnotify would be useful for?
What you might experience is that the client that is requesting to possess is trying to call functions before the server is done handling the repossess.
“Event Receive Restarted” on the possessed Pawn is an event that gets triggered on the Server and the new Owning Client. You can use “Is Locally Controlled” to ensure it is the Owning Client and not the Server side.
“Event Receive Restarted” Should be used to trigger any setup that needs to happen on Repossess on the client side like widget and camera setup.
Ahh thank you that explains a lot, I have the mesh set to reset on the server and multicast to all players on event possessed, which works on first spawn but resets the mesh when the player ‘repossesses’ their character I believe this may solve the issue, so presumably if im reading what you say correctly, rather than on event possessed. I want to run that logic locally on ‘event receive restarted?’