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.
  2. Dismiss Notice

There is no NetworkIdentity on this Object. Plz add one.

Discussion in 'Multiplayer' started by Di_o, Jun 1, 2016.

  1. Di_o

    Di_o

    Joined:
    May 10, 2016
    Posts:
    55
    Hey,

    right now I'm earning some first grey hair with my first multiplayer game. It's working quite good so far, because the tutorial explains it very nicely.

    Now I'm trying to make my players send beacons (circles that increase in size) after a double click. So I want to spawn the prefab with the animation at the players location. The prefab has a NetworkTransform and Network identity and is listed as spawnable prefab in the NetworkManager. Basicly I do everything like the tutorial tells me to.

    The problem is, Unity is coplaining about a missig NetworkIdentity in the "Object". My question is: Which object? All involved objects have Identities.

    Code (CSharp):
    1. public class TouchMyself : NetworkBehaviour {
    2.  
    3.     public GameObject beaconEffect;
    4.     public Transform myPlayer;
    5.  
    6.     private float lastClickTime;
    7.     private float catchTime = 0.25f;
    8.  
    9.     void Update (){
    10.         if (!isLocalPlayer) {
    11.             return;
    12.         }
    13.         if (Input.GetKeyDown (KeyCode.Mouse0)) {
    14.             if (Time.time - lastClickTime < catchTime) {
    15.                 CmdSendBeacon ();
    16.             }
    17.             lastClickTime = Time.time;
    18.         }
    19.     }
    20.          
    21.     [Command]
    22.     void CmdSendBeacon(){  
    23.         var beacon = (GameObject)Instantiate (beaconEffect, myPlayer.position, myPlayer.rotation);
    24.         NetworkServer.Spawn (beacon);
    25.     }          
    26. }




    EDIT: I just realized, the beacon is being spawned, but the exception is still thrown.
     
    Last edited: Jun 1, 2016
  2. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,086
    What object are you attaching this NetworkBehaviour to? it needs to be on the player prefab if you're going to use isLocalPlayer.
     
  3. Di_o

    Di_o

    Joined:
    May 10, 2016
    Posts:
    55
    Oh yeah, forgot to mention that. It's on the PlayerPrefab thats listed at the Manager.
     
  4. Di_o

    Di_o

    Joined:
    May 10, 2016
    Posts:
    55
    Ah sorry everybody, the exception was about a child of the player that was missing a NetworkIdentity. SOLVED
     
    Songshine likes this.
  5. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    83
    Please post how you solved a network identity for a child? Its not possible to add another Network Identity to it, but isLocalPlayer doesn't work without it.
     
    trombonaut likes this.
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    network identity component on a child object is possible but not a supported configuration. The way I would check isLocalPlayer on a child object would be to just have it a MonoBehavior that calls a function on a parent NetworkBehavior that actually checks isLocalPlayer.
     
    Sludgemonster likes this.