Search Unity

Unet TPS aim up/down not work

Discussion in 'UNet' started by alpezaxxx, Feb 12, 2018.

  1. alpezaxxx

    alpezaxxx

    Joined:
    Dec 20, 2016
    Posts:
    17
    i n game this S*** not working ?.everytings works well.. when i look at another player i cant see Spine rotate..
    i'm fustrated

    void LateUpdate()
    {
    RpcAim();
    }


    void RpcAim()
    {
    if (isus.aim)
    {
    Vector3 eulerAngleOffset = Vector3.zero;
    eulerAngleOffset = new Vector3(aimingX, aimingY, aimingZ);
    Ray ray = new Ray(cam.position, cam.forward);
    Vector3 lookPosition = ray.GetPoint(point);
    spine.LookAt(lookPosition);
    spine.Rotate(eulerAngleOffset, Space.Self);

    }
    }
     
  2. alpezaxxx

    alpezaxxx

    Joined:
    Dec 20, 2016
    Posts:
    17
    Help me pls
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    A ClientRpc can only be called on the server to run on all the clients. Since you aren't checking in LateUpdate() if this is the server or not, I'm assuming you're not aware of this. Also, you're not declaring the ClientRpc correctly.

    Code (csharp):
    1. [ClientRpc]  //this part is actually pretty important
    2. void RpcAim()
    https://docs.unity3d.com/Manual/UNetActions.html
     
  4. alpezaxxx

    alpezaxxx

    Joined:
    Dec 20, 2016
    Posts:
    17
    tnx, but only one player can rotate spin up/down... ??
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    No, I'm just saying you're doing it wrong.

    In the UNET HLAPI if you want to sync rotations of an object you have several options. You can use a NetworkTransform, you can send a Command from the client to the server, or send a ClientRpc from the server to the client, you could use a Vector3 SyncVar on the server to sync to the client, or you could just put all the information you want to send into a UNET Message.

    Be conscious that you should only be sending information that you really need to send.
     
    alpezaxxx likes this.