Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    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:
    2,575
    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!!