Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Updating an Animation Rigging Constraint During Editor Playback

Discussion in 'Animation' started by SticklandPWorm, Mar 12, 2024.

  1. SticklandPWorm

    SticklandPWorm

    Joined:
    Apr 20, 2017
    Posts:
    20
    Hi

    I have a manager component which fetches values on a timeline and applies them to rig weights. I would like to be able to scrub the timeslider in editor mode to view the result after IK is applied. Using ExecuteInEdit mode works fine with setting the overriding weight for a constraint but will not update the source weights when adjusting the weights of objects in a WeightedTransformArray, I assume because it needs to be copied and then reapplied. All of this works fine in Play mode.


    Code (CSharp):
    1.            constraint.weight = w;            //Updates in editor mode
    2.  
    3.            WeightedTransformArray sources = constraint.data.sourceObjects;
    4.            sources.SetWeight(0, val0);
    5.            sources.SetWeight(1, val1);
    6.            constraint.data.sourceObjects = sources; //Will not update in editor mode
    How would I be able to adjust the source weights in editor mode and see the results? Thank you for any help