Unity 5.2.3f1
Windows 10
C#
I am basically making a multiplayer board game. Players need to have a stack of tiles they can play, move, etc. that all have independant stats. I have set up a player network object with the NetworkBehaviour shown below. ass you can see most of my functions are structured fairly similarly, but I am getting VERY different results.
SceneChange and MoveTile work perfectly one bothe the client and server, as well as FRROM the client and server. StackDeck and SyncTile are another matter. Both of them execute the Command only. By this I don’t mean that the code doesn’t work right for the ClientRpc call, I mean the call doesn’t happen. Anywhere. Client or server, Unity editor or built project, developer build or not, NOWHERE does even the debug call give output from those two RPC calls, nor are errors thrown.
I am at a loss. I have been changing things back and forth trying to find a cause, or even just what makes the two functions that work different, but I’ve come up short. Any assistance would be greatly appriciated.
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using System.Collections.Generic;
using TTools;
public class TilesNetworkManager : NetworkBehaviour
{
public static TilesNetworkManager instance;
public static int netLock = 0;
private NetworkManager netManager;
void Awake()
{
DontDestroyOnLoad( gameObject );
}
void Start()
{
instance = this;
netManager = GameController.Instance.netManager;
}
public static void SceneChange( string scene )
{
instance.CmdSceneChange( scene );
}
public static void StackDeck( TileDeck savedDeck )
{
netLock++;
instance.CmdStackDeck( true, savedDeck.ToString() );
}
public static void MoveTile( Tile tile, BoardSlot slot )
{
instance.CmdMoveTile( tile.gameObject, slot.name );
}
public static void SyncTile( GameObject tile )
{
instance.CmdSyncTile( tile );
}
[Command]
public void CmdSceneChange( string scene )
{
netManager.ServerChangeScene( scene );
}
[Command]
public void CmdStackDeck( bool playerA, string deckString )
{
if( Board.Instance.deckA.Count > 0 )
{
Debug.Log("Deck B");
TileDeck savedDeck = new TileDeck();
savedDeck.FromString( deckString );
Board.Instance.StackDeck( false, savedDeck );
}
else
{
Debug.Log("Deck A");
TileDeck savedDeck = new TileDeck();
savedDeck.FromString( deckString );
Board.Instance.StackDeck( true, savedDeck );
}
RpcStackDeck(false,deckString);
netLock--;
}
[Command]
public void CmdMoveTile( GameObject tile, string slot )
{
Debug.Log("Server Move");
RpcMoveTile( tile, slot );
}
[Command]
public void CmdSyncTile( GameObject tile )
{
Debug.Log("Server Load Tile");
NetworkIdentity objNetId = tile.GetComponent<NetworkIdentity> (); // get the object's network ID
objNetId.AssignClientAuthority (connectionToClient); // assign authority to the player who is changing the color
RpcSyncTile( tile ); // usse a Client RPC function to "paint" the object on all clients
objNetId.RemoveClientAuthority (connectionToClient); // remove the authority from the player who changed the color
//GetComponent<Tile>().LoadTile( Board.Instance.roster[ID], ID );
}
[ClientRpc]
public void RpcStackDeck( bool playerA, string deckString )
{
Debug.Log("Deck B made here");
TileDeck savedDeck = new TileDeck();
savedDeck.FromString( deckString );
Board.Instance.StackDeck( false, savedDeck );
netLock--;
}
[ClientRpc]
public void RpcMoveTile( GameObject tile, string slot )
{
Debug.Log("Client Move");
Tool.StartCoroutine( Board.Instance.MoveTile( tile.GetComponent<Tile>(), Board.FindSlot(slot) ) );
}
[ClientRpc]
public void RpcSyncTile( GameObject tile )
{
Debug.Log("Client Load Tile");
int id = tile.GetComponent<TileNet>().ID;
tile.GetComponent<Tile>().LoadTile( Board.Instance.roster[id], id );
}
}