Getting player controller in multiplayer

Hello.
I need to cast to TopDownController to get Sword Slash variable. It works at server side. But its not working at clients. How can i solve it. What can i use instead of get player controller or is there any way for casting or any other way to make this work in multiplayer. Can someone help me please ?

Thank you very much. :slight_smile:

2 Likes

PlayerController is not replicated to other clients other then local machine (if im not mistaken) for security reasons as users can do anything with there PC memory. use PlayerState which is replicated extension of PlayerController and should contain all public information (not tied to pawn itself) on player that all other clients can access. Same goes with GameMode, there GameState for exact same reason

4 Likes

Thank you very much for your reply. So get player controller is not replicated what do i have to put there to access that sword slash variable.
I am begginer in unreal engine so i couldn’t make that player state things and can you give me some examples maybe blueprint examples for me to do that. :slight_smile:

Put sword slash on the pawn instead, i think.

The PlayerController should only handle communication between a specific client and the server like mentions. You may want to move that variable to the Pawn/Character or PlayerState (if it is not related to the owner of the animation). Animation Blueprints have a helper function called “TryGetPawnOwner” that you can use if you are working with animations on a Pawn object. If not you can use GetOwningActor/Component.

1 Like

I don’t know why no one else has mentioned this, but there is an alternative to player controller for multiplayer. It’s a node called Get Controller. You cast to your PC from there and then you’re not locked to a specific player index. You would run your custom event on “Owning Client” and it will grab the local Player Controller.
Some situations require you to use the Player Controller for multiplayer like “View Target with blend” for example.
GetController

9 Likes


Thanks to your comment, I implemented the image as shown in the Collab Viewer template and the controller vibrates even in multiplayer. Thank you very much.

2 Likes

No problem. I found out via Reddit so just happy to share the knowledge :slight_smile:

1 Like

I know this post is old, but the simple “controller is not replicated” just saved me!! I simply had to get my controller location from the client rather than the server. Such a small change took me hours. Thank you !

In multiplayer gaming, obtaining the player controller is like holding the key to collaboration. It’s the linchpin for managing player input and actions across the network. Ensure a seamless gaming experience by mastering the art of getting the player controller in multiplayer—where teamwork meets technical finesse. :video_game::link: