Is it possible to play animations while the TimeScale is 0? I'm talking about bone animations imported from Maya. The basic scenario is that i have a bunch of rigidbodies on screen, i'd like to "pause" the screen on a button press, which plays an animation and turns timeScale to 0. But because timeScale is 0 animations won't play at all.
Is there any way of achieving this?
I've got another method where i use delegates and events to notify objects when i've entered "pause mode", but i thought that just turning the timeScale down would be more efficient than N method calls.
//edit// One idea that i do have is that i could write an extension for the AnimationClip class for a new function to play the animation, but also pass in a flag (ignoreTimeScale), if this flag is true, then i could scrub through the animation using a while(animation.time < animation.length). Or something like that. Thoughts?
Works perfectly fine by creating an animation extension function to play the animation based on realtimeSinceStartup and a psuedo deltaTime.
Add the following function to a script called "AnimationExtensions.cs", and then you can simply call the function like so:
StartCoroutine( animation.Play("animName", false, () => Debug.Log("onComplete")) );
Play animation forward non timescale
Play animation reverse non timescale If you would like to do the same, but reverse your animations instead, you need to reverse your logic, like so:
So I copied and pasted the c# script above and get these errors in the console. I never work with C# (only JS) and couldn't work out what the problems are.. can you help?
For the main script: /AnimationExtensions.cs(1,28): error CS0116: A namespace can only contain types and namespace declarations
[is pointing to the following line in the script: public static IEnumerator Play( this Animation animation, string clipName, bool useTimeScale, Action onComplete ) ]
I pretty much did it the way you said in your edit. Base it off the timed components from the animation, and create a coroutine that I kept track of in my own List and based other functions that coincided with it off of Time.realtimeSinceStartup. This was just a helper timer to base coroutines off of since coroutine yielding is also derived form timeScale.
answered Feb 15 '12 at 07:34 PM