Developing my game I need that an Enemy throws objects every 10 seconds, for instance, against my Player. Just at the same times the Enemy should mimic with an animation clip (1 second long) the repetitive throws. I have done it all, except the script piece that could allow me make the task. I wrote a very simple line script nested in my Up Date function:
animation["Take 001"].speed = 2.0;
where "Take 001" is my animation clip and 2.0 is the speed of the animation.
This made the job, but ONLY ON THE FIRST TROW. From there on only the objects are thrown but without the animations.
Any help on this LITTLE issue! (nothing is little in this field)
I wrote down this line: InvokeRepeating (animation["Take 001"], 0, 10); but I got this error: Assets/Scripts/MonkeyAnimation.js(20,17): BCE0017: The best overload for the method 'UnityEngine.MonoBehaviour.InvokeRepeating(String, float, float)' is not compatible with the argument list '(UnityEngine.AnimationState, int, int)'. Any further advice, please?
Here is how I resolved my problem. My animation was done in Maya, therefore I made in Maya a new animation (as my animation is very simple I only invested on it five to ten minutes) with 1 second duration and 9 seconds without movement in order to fill the 10 seconds I needed. For this I compared time an frame-times with the Unity Animator (Window > Animation, with the Character selected). I imported again to Unity the Character with the new timing and wrote the line:
animation.Play("Take 001");
nested in the Up Date function in the Character script and I got the animation that I wanted synchronized with the objects launched.
I am sure there are many other ways to fix the problem, but this worked very good for me.
By the way, the imported animations from Maya, at least on my case, are not editable because they produce the message Read Only in the Unity Animator.
Could you post some more code?
– Statement