Hi there,
In several places throughout my game level, I’m using Animation-Queuing.
This is a simplified version of what I’m doing:
function Start () {
myCharacter.animation["nameOfMyAnimation1"].wrapMode = WrapMode.Once;
myCharacter.animation["nameOfMyAnimation2"].wrapMode = WrapMode.Loop;
}
function OnGUI () {
if (GUI.Button (Rect (390,120, 70, 70), "", myGUIStyle)) {
myCharacter.animation.CrossFade("nameOfMyAnimation1");
myCharacter.animation.CrossFadeQueued("nameOfMyAnimation2", 0.1, QueueMode.CompleteOthers);
}
}
… and it is all working fine, exactly as I want it to.
The problem I have is, when I restart the level (by resetting all variables, not by reloading the scene), quite often I will end up with a situation where some animations are left hanging in the queue, and suddenly become active when I don’t want them.
So my question is, is there a way to completely clear/empty the animation-queue when I want to restart a level?
Many thanks in advance…
agreed but even worse situation with CrossFadeQueued
animation.CrossFade ( name1, 0.1f );
animation.CrossFadeQueued ( name2, 1.0f );
On every
GameObject.enable = false;
GameObject.enable = true;
and in Editor log is shown me missing animation exception with name2.
I have crash either standalone windows exe and web based app.
Very very strange behave of CrossFadeQueued. We solved it by manually crafted animation graph \ queue code.
There certainly doesn’t seem to be anything in the API that clears the queue. You could file a feature request for this if it is a nuisance to be without it.
I’ve been working with animation queues and happened upon some information while trying to solve another problem. If you include the following code:
// List animations and their current time
for (var state : AnimationState in animation) {
Debug.Log(state.name + ": " + state.time);
}
You’ll see that any queued animation name will be appended with the string " - Queued Clone." So, if you’re queuing an idle animation that waits until your walk cycle has completed, for instance, you’ll see both “idle” and “idle - Queued Clone.” That means any animation you queue is a temporarily added animation with such an altered name. It also means that any queued animation doesn’t actual call your defined animation, but rather a clone of it, obviously.
I haven’t tried this myself, but I assume that cloned animation is of type AnimationClip, which means that you could probably use a Destroy function call on it. Simply sort through your list of animations, find anything with the appended " - Queued Clone" string, and destroy accordingly.
Happy queue flushing! 
I also came across this problem. I wanted a way to clear the queue, but there isn’t such a command. I tried this, and it seemed to do the trick.
animation.Stop();
animation.Play();