How to Change Max Player Count of Input Manager through Script

I wish to change the max player count of the player input manager through script for 2, 3 and 4 player mode. However, the playerInputManager.maxPlayerCount shows up as read-only and cannot be assigned.

The documentation says maxPlayerCount is of type {get; set; }, so is this just a bug? If not are there any work-arounds?
Thanks in advance.

6 Likes

same here. bump

edit:
I dont know how hacky of a fix this is but you can edit the player input manager library package and then replace:

public int maxPlayerCount => m_MaxPlayerCount;

with

public int maxPlayerCount{get{ return m_MaxPlayerCount; } set{ m_MaxPlayerCount = value; }}

thats got it working as the documentation says for me

2 Likes

I also have this problem. Bump!

The documentation says it should be settable and changing it in the Player input script reverts every time the projects loaded. Any help on a permanent fix would be great.

2 Likes

This still doesn’t seem to be fixed. Bump!

Still not working it reverts it everytime

Hi Guys,
Just came up against this problem myself, its (get; set;) but we can’t set it.

Im sure you’ve worked it out for yourself but…

As a work around Ive set it in the inspector to the max players of 4 for my game.
Each time a player is instantiated by the manager playerCount++

int myMaxPlayerCount = 3; //If we chose a 3 player game.

if(playerCount == myMaxPlayerCount)
{
playerInputManager.DisableJoining();
}

Works for me.