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

preview_player
Показать описание
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:

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 :)
Рекомендации по теме
Комментарии
Автор

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!

SmallHedgeHQ
Автор

(timestamp 8:45)
instead of a switch on check idle:

string anim = $"Idle {currentIdle + 1}"
ChangeAnimation(anim)

cdreyer
Автор

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!

federicodanzi
Автор

watching someone code like this is satisfying since im learning to code as well

bobjo
Автор

This has some drawbacks though. Consider large game with large codebase with lot of legacy code, or case when you even don't have access to some code. Then you are porting some features and in that case using animator is really convenient. Otherwise your visuals are tightly bound to code, which is not good. Or you can't give some tasks to tech / ui artists who are not that familiar with code.

sewerhrehorowicz
Автор

omg I always hated to animated in the animator now I can do it through code TYSM!

HD_
Автор

Nice video, explained really well. Keep it up!

corruptionhades
Автор

Meanwhile Unreal Engine Animation Blueprint just being superior

Sebbx
Автор

Perfect explanation and pacing. I learned a lot here, thank you!

PreRenderedRealities
Автор

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

snorQz
Автор

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)

sladnam
Автор

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. :(

nizzq
Автор

Author: "Don't use the Unity Animator"
Also author: * uses Unity Animator *
😄

FOLDIK_UA
Автор

I think Animancer could solve all problems, also would suggest using fsm in code

vailshnast
Автор

So well explained, i'll subscribe

林俊豪-sd
Автор

Amazing video! Much appreciated works great.💯

jcashbeatzrh
Автор

Hello there, I wanted to organize my Animations with state machines.
Now the Animation won't switch anymore.
I think it's because it's not in the "area" anymore.

Does anyone know if it's possible to switch between state machines and how?

Thank you for any answers!

Edit:
I'm able to access the AnimatorController and through that the Base Layer as an AnimatorStateMachine.

How could I switch the StateMachine...?

jonas
Автор

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 it should equate to 0? or when i fast tap a and d the player would walk but in the idle animation very weird

rediculai
Автор

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?

daoviettuan
Автор

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.

YggdrasSoftGaming