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

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.

public class TouchMyself : NetworkBehaviour {
  
    public GameObject beaconEffect;
    public Transform myPlayer;

    private float lastClickTime;
    private float catchTime = 0.25f;

    void Update (){
        if (!isLocalPlayer) {
            return;
        }
        if (Input.GetKeyDown (KeyCode.Mouse0)) {
            if (Time.time - lastClickTime < catchTime) {
                CmdSendBeacon ();
            }
            lastClickTime = Time.time;
        }
    }
          
    [Command]
    void CmdSendBeacon(){  
        var beacon = (GameObject)Instantiate (beaconEffect, myPlayer.position, myPlayer.rotation);
        NetworkServer.Spawn (beacon);
    }          
}

EDIT: I just realized, the beacon is being spawned, but the exception is still thrown.

What object are you attaching this NetworkBehaviour to? it needs to be on the player prefab if you’re going to use isLocalPlayer.

Oh yeah, forgot to mention that. It’s on the PlayerPrefab thats listed at the Manager.

Ah sorry everybody, the exception was about a child of the player that was missing a NetworkIdentity. SOLVED

1 Like

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.

1 Like

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.

1 Like