- Home /
UNet reconnecting bug
I'm using Unity 5.2.0f3 32-bit (since I'm using Vuforia which only seems to work with 32-bit editor) and I tried to make a simple network example where the clients share an object which changes color when the screen is clicked. When i run two clients (one being a host), it works perfectly and it is possible to see the Player object created in the host's scene. When i disconnect the remote client, it's Player object disappears from the host's scene, which is also good, but if i connect again with the same remote client, it connects but the Player object isn't created in the host's scene again, leaving the client powerless (it can't command anything).
I've searched this bug around, and I've found a few threads about it: http://forum.unity3d.com/threads/solved-server-not-adding-player-for-reconnecting-client.333171/
http://answers.unity3d.com/questions/986941/something-special-required-to-disconnectreconnect.html
Etc.
The solutions presented propose to patch Unity. The thing is, in those threads, the version in question is 5.1, and the patch being 5.1.0p1, but i am using unity 5.2, it should already be fixed.
So, what can I do to get rid of this annoying behaviour?
Edit: I decided to post my simple player script in case it is me who isn't doing it properly.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class CommanderController : NetworkBehaviour {
// Update is called once per frame
void Update ()
{
if (isLocalPlayer)
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Sending Color Command");
CmdChangeColor();
}
}
[Command]
void CmdChangeColor()
{
RpcChangeColor(new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), 1.0f));
}
[ClientRpc]
void RpcChangeColor(Color color)
{
GameObject.Find("Floor").GetComponent<Renderer>().material.color = color;
}
}