I’m experimenting with HLAPI and I’m facing a simple problem that doesn’t seem to be handled by any of the functionality provided by the netwoking system.
Let’s say I have a simple cube in the scene that starts moving when any client press a button. It seems that I can send a command to the server from a client if the client has the authority over that object, however this page sates:
http://docs.unity3d.com/ScriptReference/Networking.NetworkIdentity.AssignClientAuthority.html
Only one client can own an object at
any time
Let’s say the players have simply to cooperate based on client inputs of a central copy of the object on the server (the case of the cube), how can one make remote objects receive commands from multiple clients?
code example:
[Command]
void CmdToggleMoving(){
moving = !moving;
logger.ShowMsg("Moving: " + moving);
}
void checkObjectClick(){
if(Input.GetMouseButtonDown(0)){
RaycastHit hit;
Ray ray;
if(settings.usingVufuia)
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
else
ray = settings.selectedDebugCamera.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out hit)){
// Debug.Log("hit something " + hit.transform.name);
if(hit.transform.name == this.transform.name){
CmdToggleMoving();
logger.ShowMsg("Moving: " + moving);
}
}
}