Don't use the Unity Animator, Use Code Instead! - Tutorial

Published 2024-03-02
Unity developers often create messy animator tabs. Animating like a programmer allows you to clean it up, and have more control of your animations. This is how to set up your animations in any project.

Assets Showcased:
ENVIRONMENT: assetstore.unity.com/packages/3d/environments/plat…
POST PROCESSING: assetstore.unity.com/packages/vfx/shaders/fullscre…
FULLSCREEN: assetstore.unity.com/packages/tools/utilities/full…
PLAYER: assetstore.unity.com/packages/3d/characters/humano…
SOUND FX: assetstore.unity.com/packages/audio/sound-fx/unive…
FOOTSTEPS: assetstore.unity.com/packages/audio/sound-fx/foley…

Support me :) - buymeacoffee.com/smallhedgehq
Website - www.smallhedge.com/
My games - small-hedge.itch.io/
Twitter - twitter.com/SmallHedgeHQ
Facebook - www.facebook.com/SmallHedgeHQ

Youtube avatar created by OliGalArt, go check her out! ko-fi.com/oligalart/commissions

00:00 Intro lol
00:38 Setup
01:09 Player Movement Script
01:49 Step 1: Add Animations
02:35 Step 2: Setup Script
04:43 Step 3: Trigger Animations
04:55 Run Animations
07:00 Cycle Idle Animations
09:28 Step 4: Instant Animations
09:41 Punch Animation
10:52 Behavior Scripts
14:07 Reset Animations
15:00 Jump Animations
17:52 Hashing Animations
19:02 Outro :)

All Comments (21)
  • @SmallHedgeHQ
    Hello everyone! I just released part 2 of this video! It’s an independent animation scripting system that works with layers and animation locking (and is very easy to use). Go check it out! https://youtu.be/Db88Bo8sZpA
  • @cdreyer6266
    (timestamp 8:45) instead of a switch on check idle: string anim = $"Idle {currentIdle + 1}" ChangeAnimation(anim)
  • @bobjo1006
    watching someone code like this is satisfying since im learning to code as well
  • It's actually pretty smart but also simple. I mean, even if you use the animator transitions and variables, you need to change them by script, so why not do all the rest too? You opened my eyes, thank you!
  • @rediculai2584
    i did this it seems alot cleaner but i have problem when i press left and right (a and d) for movement the animations bug out and it starts playing the running animation but with input.getaxisraw("horizontal") it should equate to 0? or when i fast tap a and d the player would walk but in the idle animation very weird
  • @sladnam7480
    Does this work with BlendTrees as well? All of my characters directional movement is handled in a BlendTree (forward, back, right, left, ForwardRight, ForwardLeft, etc)
  • @nizzq2
    Hey, I encountered an error where the attack animation will stop playing after the first hit. I followed the tutorial shown in the video but it is not working. :(
  • @snorQz
    How do you make this work with layers? Like i want the punch just to affect the upper body and at the same time i have the walk interact with the legs
  • @daoviettuan2002
    I want to ask what happens if it applies to thousands of enemies? I want to ask if the animation clip when attacking has a length of about 2 seconds, do we have to check to run the entire animation before switching to Idle mode?
  • @Sebbx8
    Meanwhile Unreal Engine Animation Blueprint just being superior
  • @FOLDIK_UA
    Author: "Don't use the Unity Animator" Also author: * uses Unity Animator * :face-orange-raised-eyebrow:😄
  • @vailshnast
    I think Animancer could solve all problems, also would suggest using fsm in code
  • for the idle animation, wouldn't it just be easy to set the first value of currentIdle to 1, check if it's over 7 and loop it back to 1 and just have the last else call ChangeAnimation($"Idle {currentIdle}"); ??? Just kinda feels like there's no reason to add extra steps for something relatively simple. EDIT: And someone beat me to it a little further down like 3 weeks ago, sorry.