How to increase player index?

Hi, as far as I know from reading over here, each player in a game instance with one or more players has a player index value given to it. If there’s only one player that’s 0, and if there are more it’s higher (1,2…; it’s an integer), and each index is associated with a Player Controller and a Player Character (that’s why it appears a “Player Index” node in functions such as “Get Player Controller”).

I’m trying to achive a local multiplayer, so the first player has Player Index 0 and the second is to have Player Index 1; however even I’m spawning a character and then usign “Spawn Default Controller”, the Player Index remains as 0 (doesn’t increase to 1), and so it doesn’t allow input controlling the second character in that local game instance (it can be done in client-server contexts, though, but that’s not what I’m looking for now).

Player Index doesn’t automatically increase when spawning a new controller, so how can I incease player index?

Thank you for the answer. Would it be possible to create a blueprint function to execute that code?

Thanks. OK, so I will try to make a function to execute a piece of code involving CreatePlayer.

Simply creating a character and player controller is not the right way around to add a second player. You want to call CreatePlayer on the GameViewportClient. If you’re in Blueprints this isn’t currently available to you, but you can use the console command “CreateDebugPlayer 1” which will spawn a second character using controller ID 1.

Yes, it has already been done actually and should be available in the 4.2 build.

Check this answer for more information: