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
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);