Search Unity

SetLayerWeight on Unet

Discussion in 'UNet' started by yepfuk, May 9, 2016.

  1. yepfuk

    yepfuk

    Joined:
    Sep 23, 2015
    Posts:
    67
    Hi,

    I want to set layer weight when player fire, on the base layer all animations works fine both client and server but when I set the layer weight this does not seen on client.

    I tried these so far;
    - Using [Command] and Cmd function to set layer weight.
    - Using SetParameterAutoSend for each parameter.
    - Set the layer weight both normal Animator and the Network Animator

    What am I missing?

    Thank you for your answers.
     
  2. yepfuk

    yepfuk

    Joined:
    Sep 23, 2015
    Posts:
    67
    Finally I solved the issue, thank you for all your supports.

    The solution is ClientRpc method, you have to set layer weight in ClientRpc method.
     
    Harinezumi likes this.
  3. MohammadAlizadeh

    MohammadAlizadeh

    Joined:
    Apr 16, 2015
    Posts:
    26
    Hello
    Can you tell us how did you do that?
    i tried somthing like this but didn't work..just a example not a complete code:

    Code (CSharp):
    1. private float crouchWeight;
    2. private float jumpWeight;
    3.  
    4. void Update() {
    5.            if (isLocal) {
    6.             if (Input.GetButton ("LeftCtrl")) {
    7.                 Crouching();
    8.             }
    9.             }
    10.  
    11. if (!isLocal) {
    12.             RpcCrouchWeight (crouchWeight , jumpWeight);
    13.         }
    14. }
    15. void Crouching() {
    16.          _animator.SetLayerWeight (1, crouchWeight);
    17.  
    18. }
    19.  
    20. [ClientRpc]
    21. public void RpcCrouchWeight(float _crouchWeight , float _jumpWeight) {
    22.         crouchWeight = _crouchWeight;
    23.         jumpWeight = _jumpWeight;
    24.     }