Recent animations and effects in the battle. The Unity3d provides Time.timescale support for acceleration/deceleration. However, timescale provides a global time scale, and some of our actions or animations do not want to be slowed down by timescale. For example, when playing big strokes in the legend of the turret. In addition to the big strokes, all other actions/animations are paused.
The following are the Ignoretimescale methods for animation, animator, and particle effects respectively.
Animation
The Time.realtimesincestartup record is the real time that is unaffected by timescale, and it is used to play animation at every frame.
Code snippets such as the following:
// 当前动画状态// 当前真实时间// 此帧与上一帧的时间间隔// 记录此帧时间,下一帧用// 动画已播放时间animState.normalizedTime = progressTime / currState.length// 动画规范化时间[0-1]// 在当前状态对动画进行採样,当你想显式设置动画状态而且对它取样的时候使用
Animator
...;public void Update() { _animator.updateMode = AnimatorUpdateMode.UnscaledTime; // 指定该Animator更新模式为不受scale影响}
Particle effects for Particleemitter
...;public void Update() { _emitter.Simulate(Time.unscaledDeltaTime);}
For Particlesystem
...;public void Update() { _particleSystem.Simulate(Time.unscaledDeltaTime, true, false);}
Unity3d-action animation ignores timescale