Is it possible to play an animation while Time.timeScale == 0? I’m trying to play a menu animation when the game is paused.
You might want to use iTween for that - it has a convenient “ignoretimescale” option - iTween for Unity by Bob Berkebile (pixelplacement)
Also worth mentioning is Time.realtimeSinceStartup. This gives the actual game time whereas Time.time gives the time as modified by the timescale.
@technicat: Thanks for the info about iTween.
@andeeee: Yes, thanks for the link. I was considering modifying AnimationState.time based on the variable you referenced (instead of Animation.Play ()). But would prefer a nicer way to do it.
Alright, I got it to work. I’m using Time.realtimeSinceStartup along with function Update.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AnimationExtras : MonoBehaviour {
ArrayList states = new ArrayList ();
float lastRealTime = 0.0f;
public void PlayOnce (AnimationState state) {
states.Add (state);
}
// This is one of the few events called regularly while Time.timeScale is 0.
void Update () {
for (int i = 0; i < states.Count; ++i) {
AnimationState state = (AnimationState)states [i];
state.weight = 1;
state.enabled = true;
state.time += (Time.realtimeSinceStartup - lastRealTime);
if (state.time >= state.length)
states.Remove (state);
}
lastRealTime = Time.realtimeSinceStartup;
}
}
Hi
When we pause the game using “Time.timescale = 0” and then resume after some minutes, the collider were missing from the character animation. We are using five mesh collider for the character. Any solutions?
Thanks in advance