Hello , I have a problem when I use the cast of BP 's player , the image below shows the time it executes a function that the player makes an animation, as my project is online , if I use the Get Player Controller it will only run the animation on one player only , and if I use the Get All Actors he performs in all at once , wanted it to be executed only by those who push the input , as a shooter game , except that in this case one execute or any
How i get owner player to execute a function in Multplayer?
Watch multiplayer tutorials.
You should do all that stuff server side then replicate.
Client side should handle only hud and player input.
So when player presses a button to make that anim. In player controller create server side event for that action. Call it from client side of player controller, it will send event to server.
Then on server side set replicated boolean variable that tells pawn to do anim. So all pawns on server and on all clients will have that variable set, and then they can react to it.
It is a bit complicated, but:
- when you want to communicate to server you must create server side event with variables you want transfer, then call that event on client and store them on server side. That event can be in same blueprint
- to communicate back from server to clients you can replicate variables,
- pointers in multiplayer are bad idea, unless you know what you are doing, generally it is only safe to do pointers stuff on server only, clients should not get any pointers to stuff that is not controller, hud, or game state, game mode.
- game state and game mode, are your friends they always exist and are server side and replicated.