Search Unity

Transfer the coordinates

Discussion in 'Multiplayer' started by sergey_c, Mar 2, 2017.

  1. sergey_c

    sergey_c

    Joined:
    Apr 18, 2016
    Posts:
    3
    Code (CSharp):
    1.             using UnityEngine;
    2.             using System.Collections;
    3.             using UnityEngine.Networking;
    4.             public class NewBehaviourScript2 : NetworkBehaviour
    5.             {
    6.                    public GameObject shot;
    7.                 void Start()
    8.                 {
    9.                     if (!isLocalPlayer)
    10.                     {
    11.                    
    12.                         Destroy(this);
    13.                         return;
    14.                     }
    15.                
    16.                 }
    17.                 void FixedUpdate()
    18.                 {
    19.                     RaycastHit hid;
    20.                     Vector3 fwd = transform.TransformDirection(Vector3.forward);
    21.                     if (Physics.Raycast(transform.position, fwd, out hid, 10000.0f))
    22.                     {
    23.                         if (hid.collider.name == "player" )
    24.                         {
    25.                                 CmdDravHot(hid.point);
    26.                         }
    27.                     }
    28.                 }
    29.                 [Command]
    30.                 public void CmdDravHot(Vector3 h)
    31.                 {
    32.                
    33.                     RpcDravHot(h);
    34.                
    35.                 }
    36.                 [ClientRpc]
    37.                 public void RpcDravHot(Vector3 hid)
    38.                 {
    39.                     Instantiate(shot, hid, transform.rotation);
    40.                
    41.                 }
    42.             }
    43.  
    44.  









    Help me please.
     
  2. Oakioats

    Oakioats

    Joined:
    Mar 27, 2016
    Posts:
    7
    Perhaps its because your calling an RPC within a COMMAND. Also, trying debugging to see if the variable is whats giving you the issue...what I mean is, data that is set from server to client and back is best using primitive data types. I think this might only apply to syncVars, but maybe its part of the issue. Hope this helps