- Home /
How to modify ChildMotion.position via script during runtime
Hello, I want to modify the ChildMotion.position in a BlendTree during runtime, yet I am unable to set the value of it.
Here I read that you should be able to set the position ({get; set;}), yet my code does not seem to achieve this.
public void startme () {
if(eBlendTree != null){
Debug.Log("\t.::[Blend Tree]::.\nName |" + eBlendTree.name + "| & Type |" + eBlendTree.blendType + "| ECSys Length Limit: " + ECSys.LengthLimit);
for(int i = 0; i < eBlendTree.children.Length; i++){
Debug.Log("_Emotion [" + eBlendTree.children[i].motion.name + "]\n_Position [" + eBlendTree.children[i].position + "]");
Vector2 newPos = eBlendTree.children[i].position * 5;
eBlendTree.children[i].position = newPos;
Debug.Log("------" + newPos);
Debug.Log("++Emotion [" + eBlendTree.children[i].motion.name + "]\n++Position [" + eBlendTree.children[i].position + "]");
}
}
}
Here you can see the Debug.Log output:
I don't see why it is not working, there are no compiler errors, just the values are not getting updated during runtime (that could be the problem because this might be supposed to happen only in the unity editor, yet if that is so, is there another way to modify blendTree stuff during runtime?)
EDIT*** After creating a button for the editor, to call a function to change the values, the problem remained, so it is not Editor/Playmode fault, it is something else.
Just to get this out of the way: eBlendTree is an instance not a reference to a prefab or something right?
private BlendTree eBlendTree;
this BlendTree is equal to the $$anonymous$$otion of the Default State of the State$$anonymous$$achine of the BaseLayer of my Animation Controller.
eBlendTree = (BlendTree)(ac.layers[i].state$$anonymous$$achine.defaultState.motion);
In theory I should be able to SET the values, not only GET them, yet it is not working.
Your answer
![](https://koobas.hobune.stream/wayback/20220612052219im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How would I set up this blend tree for my 2d game 0 Answers
why I have to anim.getComponent in update() function when I had done in Start () function 2 Answers
First script plays animation but second script stops if from playing said animation 1 Answer
Scale up/down animator not staying at the scale once the animation finishes 2 Answers
Animating a Panel,Animating a panel 1 Answer