Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Problem with Networking Ik

Discussion in 'Connected Games' 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:
    3,574
    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.