Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Working on multiplayer FPS tutorial brackeys and having trouble on the 6th episode

Discussion in 'Connected Games' started by unity_OcNlLken2Sa_Iw, Jun 14, 2018.

  1. unity_OcNlLken2Sa_Iw

    unity_OcNlLken2Sa_Iw

    Joined:
    Feb 19, 2018
    Posts:
    9
    Hey all, I'm working on the FPS multiplayer tutorial series and I just finished the 6th episode (Shooting). I went to test the final stage of shooting and I got two errors that led to the same line of code when I shoot the player that I built:


    Error 1:

    There is no identity on this object. Please add one.

    Error 2:

    Object reference not set to an instance of an object.

    And when I double click on both of them they go to this exact line of code:

    Code (CSharp):
    1.  
    2. [Client]
    3.     void Shoot()
    4.     {
    5.         RaycastHit _hit;
    6.         if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, range))
    7.         {
    8.             if (_hit.collider.tag == PLAYER_TAG)
    9.             {
    10.                 CmdPlayerShot(_hit.collider.name); // <<<<<<<< This Line Of code
    11.             }
    12.         }
    13.  
    14.     }
    15.    
    16.     [Command]
    17.     void CmdPlayerShot(string ID)
    18.     {
    19.         Debug.Log(ID + " has been shot.");
    20.     }
    I've tried EVERYTHING. But if I don't do the whole [COMMAND] thing, it works. If not doing the [Command] above CmdPlayerShot() doesn't effect the game, then let me know!

    Thanks!

    -CB
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,355
    Are you missing a NetworkIdentity component?
     
  3. unity_OcNlLken2Sa_Iw

    unity_OcNlLken2Sa_Iw

    Joined:
    Feb 19, 2018
    Posts:
    9
  4. unity_OcNlLken2Sa_Iw

    unity_OcNlLken2Sa_Iw

    Joined:
    Feb 19, 2018
    Posts:
    9
    Never mind I got it thanks!!