- Home /
Did not find target warning when using uNet
Hi everybody,
I'm new to uNet and I'm having issues synching up the client and the server. I'm using a matchManager script to parse communication between server and clients. It is a scene object that exists only in the host (using the NetworkIdentity's "Server Only") and it handles the Command and RPCCallback methods.
The problem is that it is only communicating correctly with the host, not on the clients. I don't get any errors, but when using the editor as a client I get a "Did not find target for sync message for 1" warning and 2 "Did not find target for RPC message for 1" warnings. I honestly am not sure what these mean, or how to begin debugging for them, and I couldn't find references to these warnings in the documentation. Could anyone please point me in the right direction? In advance, thank you.
The code is below:
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class MatchManager : NetworkBehaviour {
/***************************************************
* This class controls the state of a match; this
* includes the player health, the phase each player
* is in and what cards were sent to each other
* it only runs on the host
* ************************************************/
[SyncVar] public Turn_Manager turnManagerPlayerOne;
[SyncVar] public Turn_Manager turnManagerPlayerTwo;
public bool waitForPlayerFlag = false;
[Command]
public void CmdSetPlayer(int _playerID, GameObject _matchManagerGO)
{
// get the appropriate turnmanager
var _turnManager = _matchManagerGO.GetComponent<PlayerNetworkSetUp>().GetTurnManager ();
// if the id is 0, then its the host
if (_playerID == 0) {
turnManagerPlayerOne = _turnManager;
// if not its the second player
} else if (_playerID == 1) {
turnManagerPlayerTwo = _turnManager;
// if there's no one, there is an error
} else {
Debug.LogError ("there is no such thing as a player " + _playerID);
}
// if we are not already waiting, start waiting
if(!waitForPlayerFlag)
StartCoroutine ("WaitForTwoPlayers");
}
IEnumerator WaitForTwoPlayers()
{
// set the waiting flag
waitForPlayerFlag = true;
// while enabled
while (this.enabled) {
// if we don't have both players keep waiting
if (turnManagerPlayerOne != null && turnManagerPlayerTwo != null) {
Debug.Log ("we have two players");
RpcSetPlayerOneTurnPhase(Turn_Manager.TurnPhase.ForgePhase);
RpcSetPlayerTwoTurnPhase(Turn_Manager.TurnPhase.ForgePhase);
break;
} else {
yield return new WaitForEndOfFrame();
}
}// end while
}//end coroutine
[ClientCallback]
[ClientRpc]
void RpcSetPlayerOneTurnPhase( Turn_Manager.TurnPhase _newPhase)
{
Debug.Log("sending instruction to player one to go to "+_newPhase);
turnManagerPlayerOne.SetCurrentTurnPhase (_newPhase);
}
[ClientCallback]
[ClientRpc]
void RpcSetPlayerTwoTurnPhase( Turn_Manager.TurnPhase _newPhase)
{
Debug.Log("sending instruction to player two to go to "+_newPhase);
turnManagerPlayerTwo.SetCurrentTurnPhase (_newPhase);
}
}
The CmdSetPlayer method is called from playerNetworkSetupScript.
Answer by awalltoo · Oct 26, 2015 at 03:57 PM
I'd guess that the issue is that this object exists only on the server. Whenever it tries to sync the value of one of its SyncVars or call an Rpc, it tries to find the matching object on the client, but that object doesn't exist. Ultimately, giving an object SyncVars or synchronized function calls and then making it exist only on the server kind of work at cross-purposes. Given what you're trying to do, you're probably best off unchecking the "Server Only" box on this object.
Hey Guys!
We just started with Networking for Unity in our class at university. I get the same warning message, but i cant find an object in our scene where we checked the "Server Only" box for the network Identity component - is there any other possible origin for this warning ?
$$anonymous$$y second question to this topic: What does this warning tell me? It doesnt seem to have an effect, since everything still works as intended.
Hope im not making up too big topics right now, if so im sorry for bothering!
Thanks a ton. The object was set to server only from where i was sending the clientrpc commands. Removing server only check fixed it.
Answer by yoHasse · Jan 30, 2018 at 02:24 PM
For anyone having the same error but the solution doesn't work:
I had two NetworkTransformChild components that tried to access two disabled GameObjects. Be sure that every enabled network component is able to access their specified gameobject/component
Answer by MostHated · May 07, 2018 at 04:39 PM
Is there a way to know what something is trying to access, or to see what things netid's are?