Search Unity

  1. Unity 2019.1 beta is now available.
    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. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    4,395
    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.