Revoke control when a client disconnects

Options
From my tests It seems that an entity doesn't lose its controller if the controlling client disconnects (which seems a bit weird?). entity.isControlled will keep returning true after the controlling client has disconnected.

So I'm guessing the best way to solve this is by running RevokeControl() from the host. This is an attempt at that:
public override void Disconnected(BoltConnection connection)
{
foreach (BoltEntity e in connection.HasControlOf)
{
if (e.isOwner) e.RevokeControl();
}
}
It gives: InvalidOperationException: Collection was modified; enumeration operation may not execute.

So I assume this is too late to look at what a connection has control of. Anyone got a better way of revoking control?

Comments

  • ddd
    Options
    store the entites in the connection.UserData

    look @ ServerCallbacks.cs, Player.cs and ExtensionMethod.cs from the tutorial.

    -dmg
  • chr
    Options
    Perfect. Thanks!

    (to anyone visiting this thread later: look at the sample you get with Bolt from the Asset Store. The tutorial on the web is very different)