Confused by "There is already a player at that playerControllerId for this connections."

this connections?

2948589--218527--Screen Shot 2017-02-05 at 11.38.53 PM.png

I have no idea what this is supposed to mean. The plurality is confusing me. Does it mean the PlayerControllerID has to be unique across all connections? Does it mean that I’m passing the same number twice into AddPlayer?

I debugged the value of SeatNumber (2 seats per client…) and it was different each time.

ClientScene.AddPlayer((short) SeatNumber)

I am calling AddPlayer like the above. SeatNumber is an enum (starts at 1, goes to 2, etc). Does this mean the controllerID pass into AddPlayer needs to be unique for all clients? I was under the impression it only had to be unique for that physical device.

In this testing case, I am creating 2 separate PlayerControllers per client. One for each person at the machine.
However, I am testing with 2 unity processes using the UNet matchmaker.

What’s going on here?

1 Like

Thing get even stranger. When I call ClientScene.AddPlayer - there are zero players. Afterwards… there are two:

2948659--218541--Screen Shot 2017-02-06 at 1.05.09 AM.png

How does an object with a NetworkID set to null come to exist??

Figured it out. An empty PlayerController() object is created to fill all of the player controller slots if you use a number greater than 0 for your first player controller ID.

https://bitbucket.org/Unity-Technologies/networking/raw/2bdd9961092c4a73443c09694cff5dde9e56f9f1/Runtime/ClientScene.cs

// fill out local players array
while (playerControllerId >= s_LocalPlayers.Count)
{
s_LocalPlayers.Add(new PlayerController());
}

Therefore, make sure you start your enumeration of ControllerIDs from zero… I used 1 like a human being instead of a programmer :wink: