Hi! My game is multiplayer and It works via Steam and via local LAN.
I want to be able to have multiple local players in each client (for example 2 players in one client, split screen, single player in other client, 4 players in other client, whatever).
I spawn the new characters in the server and then in the client I create a new local player and as it is a local player I will drive all those clients using multiple joysticks (simple controller plugin) via IDs, etc.). So I cant Posses a character in my clients local player because posses must be done in the server. So my solution is just take the local player, the character and make a set view target with blend to have the character view for each local player.
the problem I have is that set view target with blend is just working in the server/client and not on clients. I check everything else and is valid. The spawns are replicated, are valid, I can read stuff from them in the clients, etc, but I just cant get the viewpoint of the spawns in the local players when those local players are in a pure client terminal.
Ok. After a long time of trying and testing, I came to understand how local players work, and they are quite tricky.
Even though they are local players and supposedly don’t exist on the server, the PlayerControllers for these local players DO exist on the server. So, if you create a local player and want to store its PlayerController in a variable from the client, it will store null because the PlayerController hasn’t been created on the server yet. If I create 3 local players from my client-side PlayerController, I will have 4 PlayerControllers on the client. But if I check on the client/server after that, there are 5 PlayerControllers (the local one and the 4 client-side ones). If I then do the same on the client/server, there will be 8 PlayerControllers on the server (the default (0), the 3 created ones, and the 4 from the client). In fact, the index numbers are still respected: initially, on the server, PlayerController(0) is the local one, and PlayerController(1) is the client’s. But if the server creates a local player at index 1, it will push the client’s PlayerController index by one, so it becomes index 2.
So the solution to manage the local PlayerControllers on a client is to create them and then after a small delay get their references using Get Num PlayerControllers and a for loop, knowing that Controller(0) is the current default PlayerController of the client, and the next ones are the local PlayerControllers. Clients don’t see local PlayerControllers of the server/client or other clients; they only see their own. The only one that sees all local and remote PlayerControllers is the server.