Change animation speed in animator in child of prefab
I have a Prefab which has an empty gameobject. A child of it is animated with Animation(CTRL+6) so it has the Animator Component. From outside i now want to change the animation speed of that specific animation.
i tried: MolePrefab.GetComponentInChildren()["MoleUp"].speed = cur_animspeed; and MolePrefab.GetComponentInChildren().speed = cur_animspeed; but none works.
The first just don't have that option. The second gives me a null reference.
Any Idea how this works?
Thanks in advance
Answer by OctoMan · Oct 07, 2015 at 11:35 PM
It seems i can only do that directly in the already Intantiated prefab. I tried to change the prefab itself, thats why i got null reference.
Mole.GetComponentInChildren<Animator> ().SetFloat("MySpeed", MoleAnimSpeed);
Your answer
Follow this Question
Related Questions
Animation clip not playing but still affecting components of other clips 0 Answers
Animator doesn't change animation in Update() function 0 Answers
3D Walk animation script errors 1 Answer
Animation clips using different start value for Y 0 Answers
Walking animation of character appear broken when combined with NavMesh Agent 0 Answers