Search Unity

Resolved Unable to add to Twist Nodes list at runtime (Twist Correction component)

Discussion in 'Animation Rigging' started by Graham-B, Aug 27, 2020.

  1. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    I am trying to set up a character dynamically at runtime, and I'm running into an issue with the Twist Correction component. When trying to add transforms to the Twist Nodes list, nothing gets added.

    Code (CSharp):
    1. TwistCorrection twistCorrection = twistGameobject.AddComponent<TwistCorrection>();
    2. twistCorrection.Reset();
    3. twistCorrection.data.twistNodes.Add(new WeightedTransform(twist1.transform, 0.65f));
    I've also noticed that the add button in the inspector is grayed out when in play mode. Is it not possible to add them in play mode?
     
  2. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Solution:
    Code (CSharp):
    1.         WeightedTransformArray sources = new WeightedTransformArray();
    2.         sources.Add(new WeightedTransform(twist1.transform, 0.65f));
    3.         sources.Add(new WeightedTransform(twist2.transform, 0.8f));
    4.         twistCorrection.data.twistNodes = sources;