Search Unity

[Poll] What's faster in performance? Animation or Scripting

Discussion in 'Editor & General Support' started by qaisAhm, Dec 13, 2018.

?

What's faster?

  1. Animation

    35.3%
  2. Scripting

    64.7%
  1. qaisAhm

    qaisAhm

    Joined:
    Nov 21, 2015
    Posts:
    9
    Say you have a door you want to rotate, you can either...

    Play a rotation animation or set the transform.rotation directly

    What's faster and why?
     
  2. Define "faster".
    - faster to write it once?
    - faster to tweak when needed?
    - faster as in runs faster on the device?
     
  3. qaisAhm

    qaisAhm

    Joined:
    Nov 21, 2015
    Posts:
    9
    Faster as in performance on the device, animations take longer to setup and make changes to.
     
  4. In a case of a simple open the door, probably the simple animation is the best choice, then your own script and lastly the animator.
    And this is because the animation probably optimized enough to handle simple animations, your code will do the same eventually if you put enough work in it. Animator is a beast, it does not really worth the resources just for a simple door animation.
    But this is just a gut feeling, if you want to know exactly, build it and measure it. Never accept less than the hard data.
     
    homemacai and qaisAhm like this.
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    Using the Unity Profiler provides you with the ability to measure what's faster. Here are a few resources that should help you to get started with the Unity Profiler.

    Learn how to diagnose common performance problems and optimize your projects:
    https://unity3d.com/learn/tutorials/topics/performance-optimization