Unity3D, unity
Recently, Unity3D provides Time. timeScale support for animation and special effects during combat. However, timeScale provides global time scaling, and some of our actions or animations do not want to be slowed down by timeScale. For example, when playing big moves in the legend of the turret, all other actions/animations except the big moves are paused.
The following are the ignoreTimeScale methods for Animation, Animation, and particle effect.
Animation
The Time. realtimeSinceStartup record is the real Time not affected by timeScale. It is used to play Animation at each frame sampling. The code snippet is as follows:
AnimationState animState = animation [clipName]; // The current animation state curTime = Time. realtimeSinceStartup; // current real time deltaTime = curTime-lastFrameTime; // The time interval between this frame and the previous frame lastFrameTime = curTime; // record the time of this frame, the next frame uses progressTime + = deltaTime; // animState of the animation playback time. normalizedTime = progressTime/currState. length; // animation normalization time [0-1] animation. sample (); // Sample the animation in the current state. This parameter is used when you want to explicitly set the animation state and Sample it.
Animator
Animator _ animator =...; public void Update () {_ animator. updateMode = AnimatorUpdateMode. UnscaledTime; // specify that the Update mode of the Animator is not affected by scale}
Particle effect
ParticleEmitter _emitter = ...;public void Update() { _emitter.Simulate(Time.unscaledDeltaTime);}
For
ParticleSystem _particleSystem = ...;public void Update() { _particleSystem.Simulate(Time.unscaledDeltaTime, true, false);}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.