Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Unity Multiplayer Did not find target for sync message for INT

Discussion in '5.2 Beta' started by darthbator, Sep 7, 2015.

  1. darthbator


    Jan 21, 2012
    Hey everyone! So I updated to the 5.2 to beta to try out some local client authority for non player objects stuff. However now I sometimes run into an error where I get a stream of the following errors after attempting to spawn an object using the new NetworkServer.SpawnWithClientAuthority method.

    Failed to spawn server object, assetId=97a930354a294796871877fbafcd34 netId=21
    Did not find target for sync message for 21

    I am assuming the integer at the end of that last line is the networkId of the object. When I look on the server the object appears to have correctly spawned but it doesn't seem to ever make it back to the clients. Here's how I am spawning the object.

    First the player object request the server to spawn a new item.

    Code (CSharp):
    1. [Command] public virtual void CmdRequestItem (int itemIndex) {
    2.         Item newItem = Instantiate(ItemDispenser.Instance.items[itemIndex]) as Item;
    3.         newItem.transform.position = transform.position;
    4.         NetworkServer.SpawnWithClientAuthority(newItem.gameObject, gameObject);
    5.         newItem.PlayerTag = gameObject.tag;
    6.     }
    On the last line before I'm out I set an owner tag on the item that is guaranteed to be unique to that particular player. That sync var will then resolve parenting for the object across all clients in the below method. I don't really think this has anything to do with the issue (as it's not reporting issues and it works perfectly with the older NetworkServer.Spawn) call.

    Code (CSharp):
    1. [SyncVar(hook="SetOwner")] public string PlayerTag;
    3. //Set player tag callback
    4.     public void SetOwner (string playerTag) {
    5.         transform.SetParent(GameObject.FindGameObjectWithTag(playerTag).transform);
    6.         wielder = transform.parent.GetComponent<Player>();
    7.         wielder.ActiveItem = this;
    8.     }
    It just seems like every so often objects spawned with that new method just never make it to clients, and there doesn't appear to be a bunch of debug information about what happened there. When I look on the host the item does appear to exist for that client player on the server.

    Really all I've changed about this object spawning system is the call to the new SpawnWithClientAuthority method. Any help is most appreciated! Being able to send commands from non player objects is going to be a really pleasant way to cleanup some code in this project!
  2. darthbator


    Jan 21, 2012
    Helps when I actually register those prefabs as spawnable huh.. ugh. I looked and couldn't find a delete button. It's probably right in front of my face like the answer to this issue. Also client authority is rad. GOOD NIGHT EVERYONE!!!
    NWin and superpig like this.