Search Unity

  1. Unity 2018.3 is now released.
    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. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. 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:
    3,980
    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.