Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question DOTween vs Unity Animations for simple object animations?

Discussion in 'Animation' started by Lutenar, Dec 20, 2022.

  1. Lutenar

    Lutenar

    Joined:
    Dec 2, 2018
    Posts:
    4
    Hello!

    First post here, yay! Just got my hands back on Unity, trying and testing stuff. Kinda 3-weeks-still-a-noob here.
    I was wondering which system to use for relatively basic movements on objects.

    My example is a physical button in world (not UI) that you push to trigger something somewhere else. I tried using build-in animation system, works great, but I had to create 2 animation files (push & release) and put an animator component on the gameobject. I then trigger the animation state play when I push the button.

    I just tried DOTween and I've got the same result (close enough) using 3 lines of code in my button controller.

    What's the best method? Performance-wise, like if in the case I have a lot of buttons?

    Do you think of any better solution? I heard of Playables but didn't fiddle with it yet.

    Many thanks!!
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,976
    DOTween should be much more performant, especially if by "built-in animation system" you mean the animator / playables, which has too much overhead for simple animations.
     
  3. unity_I8FaTX-tZFc4lA

    unity_I8FaTX-tZFc4lA

    Joined:
    Aug 23, 2020
    Posts:
    4
    Personally, I would not recommend to use DOTween for your animation except if you really, really, really need performance. As a beginner, you should not even think about that till the moment your game start to lag. That being said, DOTween can be use for a variety of thing, not just animation. By exemple, you could use it for movement of a projectile or a camera. You could even use it to feed the animation controller.

    Some reason why I would recommend you to use the animator controller:
    • It is easier to work with the animator controller. You do not need to be a developer to be able to create animation. Every Unity user knows the animator controller.
    • You will need to use the animation controller if you want more complex animation. Adding a second library for the animation will make it harder to maintain your project.
    • The animator controller is more flexible. If you change your idea and you need more complex animation you wont need to convert anything.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,976
    Having dozens more animators than you really need is a quick way to lose performance without you knowing why. In fact Unity used to suggest as a "pro tip" to not use the animator if you cared about performance.

    (there have been some optimizations to the animator recently, after years of it being abandoned, probably because the DOTS animation won't be ready for a while so it will stick around for quite a while longer, but stuff like this: https://forum.unity.com/threads/we-...ained-30-fps-alternatives-to-mechanim.540162/ are probably still very relevant).

    I would agree with the above advice if we were talking about legacy Animation, but that is in semi supported status and can open a separate can of worms.

    Animator controllers may be more flexible, but they are also very prone to things getting out of hand, fast, and then you need to spend time organising them and debugging them.

    Tweening is more predictable and a good habit to get into for simple animations.

    And, finally, sure, you can use animators and wait until you get a performance issue, but then solving that performance issue is not really easy, or very possible. It's not like you can easily rip out all animators and replace them with tweens with the press of a button. You will probably need to refactor a ton of stuff and complete trash your animator work and start from scratch.

    Learning how to use tweens effectively is a very useful tool, you should get in the habit of using. Then you can decide if you want to use the animator for some stuff for the extra comfort.
     
  5. Lutenar

    Lutenar

    Joined:
    Dec 2, 2018
    Posts:
    4
    Thanks for the answers!

    Yes I was talking about the animator, sorry!
    I always tend to try and get the better system, and I know I'm thinking about performances at an early prototyping stage when I shouldn't, it's costing me a lot of time ahah.
    I planned to use DOTween for the UI anyways, so I figured I might use it for simple anims that don't require states.
    I get your point. But I love code! It's fun to tinker with the animator, more fun to do it with code :D
    I know I'll have much more complex animations and I certainly will use the animator controller for those!
    I was thinking about that as well, but the word "Legacy" doesn't strike me as good for the longer term!