show mouse cursor enable on clients [multiplayer]
hey guys. i've been looking around for long time now and i can't find a similar question or explanation about this topic. i try to give you a simple look into my situation.
problem: what i'm trying to do is to enable show mouse cursor when possessing a pawn. that works perfectly for the server but not for the clients. the cursor won't show on the clients.
what am i doing: i do have a playercharacter which enters a triggerbox to possess a new pawn. with the possession event i cast the playercontroller to enable the mouse cursor. for the server it shows, for the clients not.
the possession and the cast are properly set up (target and everything is set, i tried/watched/red alot about similar problems and i'm aware of the default input processing procedure).
so what am i missing? i know that the playercontroller is not replicated to the clients, so do i have a problem with that? do i need to bring that info back down to the clients?
i'm happy for every thoughts you got, really desperate looking for some hints... thanks alot in advance for thinking about it. just let me know if you need more info, because i haven't found any similar topics about that problem..
asked Sep 30 '16 at 11:37 AM in Blueprint Scripting
To show the mouse cursor, you're using "Get Player Controller", with the index set to 0. That works fine in a single player game where the player is alone, which means he's 0, the first index.
In multiplayer however, the SERVER is always 0 - the first "player". In a multiplayer game you should never use "Get Player Controller", and instead reference certain controllers directly. In your case, you can simply set the index to 1, and client1 will have their mouse shown, however this is bad practice, UNLESS you will only ever have 2 players, server and client1.
Finally, the reason your print was showing "correctly", server and client1, is because the both the server and clients have their own instance for basically everything, EXCEPT the playercontroller, where only ONE exists per player. This is super important to understand when coding for multiplayer.. So, the print fires once for the server using its instance, and once for the client.
P.S. cool looking game.
Follow this question
Once you sign in you will be able to subscribe for any updates here