Recent animations and effects during the battle, 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, all other actions/animations are paused except for the big trick effects.
Below are the Ignoretimescale methods for animation, animator, and particle effects respectively.
Animation
The Time.realtimesincestartup record is the real time that is unaffected by the timescale, and it is used to play animation at each frame of the sample. The code snippet is as follows:
// 当前动画状态// 当前真实时间// 此帧与上一帧的时间间隔// 记录此帧时间,下一帧用// 动画已播放时间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);}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Unity3d-action animation ignores timescale