Search Unity

Question Animation plays faster when there is lower FPS

Discussion in 'Scripting' started by chef_chicken, May 27, 2023.

  1. chef_chicken

    chef_chicken

    Joined:
    Oct 30, 2021
    Posts:
    5
    Hey, I'm having some trouble with my code where the animation would play faster when there are lower fps. Does anybody know how to fix this?

    gun.speed = move_z * Time.deltaTime + Mathf.Abs(move_z) * 5 + move_x * Time.deltaTime + Mathf.Abs(move_x) * 5
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,738
    What is gun.speed? If it's the animation speed you do not want to include Time.deltaTime in your calculations. You only do that when YOU are accumulating a time-value. In this case you're setting a rate (speed) for the animator.

    Otherwise,

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
     
    Nad_B likes this.
  3. chef_chicken

    chef_chicken

    Joined:
    Oct 30, 2021
    Posts:
    5
    oh ok, thank you
     
  4. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    Yep, Unity animations are already multiplied by time.deltaTime, that's why when you set time.TimeScale to 0.5, animations play at half speed, and they completely pause when you set it to 0.
     
  5. chef_chicken

    chef_chicken

    Joined:
    Oct 30, 2021
    Posts:
    5
    Thank you