Search Unity

Problem with Networking Ik

Discussion in 'Multiplayer' started by philipwlodarczyk42, Oct 10, 2018.

  1. philipwlodarczyk42

    philipwlodarczyk42

    Joined:
    Oct 1, 2018
    Posts:
    4
    This script works for aiming but does not go over the network even though I have a network transform and animator, what could I add/change to make this work over the network? Both targetPos and targetQuat have syncvar attached to them.
    void OnAnimatorIK()
    {
    if (!isLocalPlayer)
    {
    return;
    }
    if (animator)
    {
    //if the IK is active, set the position and rotation directly to the goal.
    if (Input.GetKey(KeyCode.LeftShift))
    {

    animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 0);
    animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 0);
    animator.SetLookAtWeight(0);
    }
    else
    {
    if (lookObj != null)
    {
    animator.SetLookAtWeight(1);
    animator.SetLookAtPosition(lookObj.position);
    }
    // Set the right hand target position and rotation, if one has been assigned
    if (rightHandObj != null)
    {
    animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
    animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
    animator.SetIKPosition(AvatarIKGoal.RightHand, targetPos);
    animator.SetIKRotation(AvatarIKGoal.RightHand, targetQuat);
    }
    }

    }
    }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Use code tags to make your code readable. I don't understand what you are trying to network here. You're currently calling return if the machine isn't the local player, so none of that code is going to run on any other machine. You're also not setting targetPos or targetQuat anywhere in the code you've posted.