Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. 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,957
    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!!