Search Unity

Question two bone ik constraint not working

Discussion in 'Animation Rigging' started by cesar121321432, Aug 13, 2023.

  1. cesar121321432

    cesar121321432

    Joined:
    Jul 11, 2020
    Posts:
    20
    Hello, i have a gun with ik target that is attached to the two bone ik constraint target at run time by this script:
    Code (CSharp):
    1.  public TwoBoneIKConstraint rightHand;
    2.     public GameObject makarov;
    3.     // Start is called before the first frame update
    4.     void Start()
    5.     {
    6.         if(!IsOwner) { return; }
    7.     }
    8.  
    9.     // Update is called once per frame
    10.     void Update()
    11.     {
    12.         if (!IsOwner) { return; }
    13.  
    14.         if (makarov.activeSelf)
    15.         {
    16.             Debug.Log("tttt");
    17.             rightHand.data.target = makarov.transform.Find("RIghtHandIK");
    18.  
    19.         }
    20.     }
    but the arm doesnt follow the target:


    (vid starts at 0:23 seconds)
     
  2. cesar121321432

    cesar121321432

    Joined:
    Jul 11, 2020
    Posts:
    20
    SOLVED:
    add:
    Code (CSharp):
    1. RigBuilder.Build();
    after changing the IK target in script
     
  3. humbercraft140

    humbercraft140

    Joined:
    May 2, 2021
    Posts:
    1
    This is not the thing I'm looking for. But, for future people, it's much more efficient and easier to have a target always assigned to the two bone constraint and then just move the target in the code instead of changing the actual target.