I want to do enter in the car for multiplayer. I made the possess when pressed enter in the car key. When i play in the client window and come near the car and press the key possession happened in the server window. How fix that?
Possession events are only executed on the server for multiple reasons.
Does this cause a game-play problem?
Yes, how i say, when i press enter in the car key playing as client nothing happen but i know what the pressing on the key is working. But in that time on the server window i see what possession work for server player and i can drive playing as server player. I run the project for 2 players without dedicated server and see 2 windows: the first for server and the second for client.
Try making “Enter In The Car” in the ThirdPersonCharacter (the one without input parameters) “not replicated”, remove all the “Switch Has Authority” from the ThirdPersonCharacter and see how it goes.
I can’t really track the flow with that many Authority checks around server only events. You can maybe debug the the second player character in the server window and see where it breaks.The chain that bothers me is:
On Acton Press → Check if is Remote → Call Event on Server → Check if has Authority → Call another Event on Server in GameMode → Check if has Authority → Posses which again is only on the server.
Try to simplify that.
That’s some overly defensive programming. You don’t need an authority check in a server only function, by definition it can only execute on the authority machine.
Similarly you don’t need to check that GameMode is valid before trying to cast it, cast will simply fail if the input object is null/invalid.
Also GameMode does not exist on non-server machines.