- Home /
 
               Question by 
               Naufalafif2015 · Mar 02, 2021 at 09:23 AM · 
                animationpackagerigging  
              
 
              Change Source Objects Weight With Code
 Can somebody make an example of code for changing weight from Source Objects? I know how to change the Script Weight, But i don't know how to change the Weight from Source Objects
 Can somebody make an example of code for changing weight from Source Objects? I know how to change the Script Weight, But i don't know how to change the Weight from Source Objects
 
                 
                source.jpg 
                (45.2 kB) 
               
 
              
               Comment
              
 
               
              Answer by pauldarius98 · Mar 02, 2021 at 11:54 AM
I had to search a bit for this but got it to work:
 MultiAimConstraint multiAnimConstraint = GetComponent<MultiAimConstraint>();
 var sources = multiAnimConstraint.data.sourceObjects;
 sources.SetWeight(0, 0.29f);
 sources.SetWeight(1, 0.49f);
 multiAnimConstraint.data.sourceObjects = sources;
Just make sure that the index is valid
Answer by Sungurr · Mar 25 at 05:20 PM
using UnityEngine.Animations;
var aim = GetComponent(); ConstraintSource a = new ConstraintSource(); a.sourceTransform=transform.parent; a.weight=1; aim.SetSource(0,a);
Your answer
 
 
             Follow this Question
Related Questions
install Animation Riggit 0 Answers
Animation Rigging package issue 0 Answers
Why can't the weight of IK constraint be keyframed with Animation Rigging package? 0 Answers
Use blender IK bones in Unity 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                