Search Unity

How to access animation rigging components in script?

Discussion in 'Animation Rigging' started by homer_3, Sep 10, 2020.

  1. homer_3

    homer_3

    Joined:
    Jun 19, 2011
    Posts:
    111
    I need to be able to change the weight of one of the animation rigging components at runtime. Where do I find the class names of the components to reference in my script? Right now I'm trying to access the Two Bone IK Constraint, but this really goes for any of the components.

    I'm using 2019.3.4f1. I tried "using UnityEngine.Animations.Rigging;" but it says Rigging does not exist. I have the animation rigging preview package installed.

    Edit: Got it working for now by moving the animation rigging package out of the packages folder and into the assets folder. Probably not the intended way for it to work though.
     
    Last edited: Sep 10, 2020
  2. Mauro02

    Mauro02

    Joined:
    Feb 3, 2021
    Posts:
    2
    do you import the Animation Rigging from the Package Manager?
     
  3. sovtek

    sovtek

    Joined:
    Oct 8, 2019
    Posts:
    9
    Not sure if it's helpful but I had a similar problem and was just missing the "Using" line for the rig.

    Code (CSharp):
    1. using UnityEngine.Animations.Rigging;
    I also found the animation rigging package has some sample files you can import. The script "mParent" has some interesting pointers on how to access weight values.
     
  4. iA7MDoVe

    iA7MDoVe

    Joined:
    Jun 14, 2021
    Posts:
    1
    try clicking on it from the scene view
     
    ayato1026ayato likes this.
  5. grempire

    grempire

    Joined:
    Sep 28, 2019
    Posts:
    3
    Examples:
    gameobject.GetComponent<OverrideTransform>().data.constrainedObject = constraintObj;
    gameobject.GetComponent<TwistChainConstraint>().data.tip = constraintObj;
    gameobject.GetComponent<TwistChainConstraint>().data.root= constraintObj;
     
    Last edited: Jan 5, 2022
  6. d0rkza

    d0rkza

    Joined:
    Feb 28, 2015
    Posts:
    6
    I'm a bit late to the discussion, but for anyone else getting the same issue, go to the packages folder in your project, right-click on any of the folders, and click "Open C# Project" and Visual Studio will now know where to look.

    upload_2022-9-3_17-41-8.png
     
  7. ShmEmad

    ShmEmad

    Joined:
    Feb 29, 2020
    Posts:
    1
    Thanks
    It's work for me
     
  8. ujz

    ujz

    Joined:
    Feb 17, 2020
    Posts:
    29
    Hello I tried everything mentioned here and still my VSCode could not recognize UnityEngine.Animations.Rigging. Finally I came across this thread, which pointed out that there was a specific bug with csproj files in the VSCode package version 1.2.4.

    So I updated my Unity package for Visual Studio Code Editor to version 1.2.5, unchecked all boxes and regenerated project files as described in that thread, and it finally worked. Just leaving here for future reference.
     
  9. MandSFun

    MandSFun

    Joined:
    Mar 15, 2023
    Posts:
    3
  10. omrisami3

    omrisami3

    Joined:
    Nov 9, 2021
    Posts:
    1
    Thank you bro !
     
  11. smash-ter

    smash-ter

    Joined:
    Sep 6, 2020
    Posts:
    22