Version: 1.5
LanguageEnglish
  • C#

Animator.SetUpdateFrequencyMode

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Declaration

public void SetUpdateFrequencyMode(AnimatorUpdateFrequencyMode mode, float frequency);

Parameters

mode Update frequency mode.
frequency Update frequency value.

Description

Set the update frequency of the Animator.

This method allows you to set the update frequency of the Animator, the value of the parameter frequency determined by the AnimatorUpdateFrequencyMode. frequency value that do not meet expectations are automatically adjusted, and the Animator is updated no more frequently than PerFrame.

In the example script below, reducing the frequency of animation updates for a performance boost.

using UnityEngine;

public class Example : MonoBehaviour { Animator m_Animator;

void Start() { //Get the Animator attached to the GameObject you are intending to animate. m_Animator = gameObject.GetComponent<Animator>(); }

void Update() { //The animation is updated every 4 frames m_Animator.SetUpdateFrequencyMode(AnimatorUpdateFrequencyMode.FixedFrame, 4); //The animation is updated every 0.1 seconds m_Animator.SetUpdateFrequencyMode(AnimatorUpdateFrequencyMode.FixedTime, 0.1f); //Revert to update per frame m_Animator.SetUpdateFrequencyMode(AnimatorUpdateFrequencyMode.PerFrame); } }