Тёмный

Godot Recipes: Animation States 

KidsCanCode
Подписаться 61 тыс.
Просмотров 106 тыс.
50% 1

Using the animation state machine to manage your animations.
Art by Elthen: elthen.itch.io/
Text version: godotrecipes.com/3.x/animation...
Support me on Patreon: / kidscancode

Опубликовано:

 

15 май 2019

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 152   
@lucasnievas4890
@lucasnievas4890 2 года назад
Just the first 10 seconds summarize my entire morning
@charonwave
@charonwave 2 года назад
same
@BK-id6pc
@BK-id6pc 5 лет назад
Another great video. In my mind you do the best videos in the field of game development. No other channel has taught me as much as your one. Please never stop sharing these great videos with us. :)
@salvadorm7564
@salvadorm7564 5 лет назад
Awesome video as always. Thank you for all the effort you put into your content.
@robotscanplaydev6939
@robotscanplaydev6939 2 года назад
This is so much easier than every other tutorial on animations trees out there. Works out of the box. Thanks Chris!
@CRYsistem
@CRYsistem 5 лет назад
You're a life saver mate, this is exactly what i was looking for, thank you!
@Pspisripoff
@Pspisripoff 3 года назад
Wow, godot added statemachine! Niiice! Thank you KidsCanCode for the tutorial! Amazing job!
@drakibble2199
@drakibble2199 5 лет назад
Thank God for this! My animation script was a jumble of awful if statements lol. Thank you for these videos, I know that you dont get a lot of views, but I appreciate every video.
@gargoyled_drake
@gargoyled_drake 2 года назад
i personally find the if statements easier to keep track of than both having to keep track of if statements, travel commands and the animationtree this made everything more complicated for me, but also seems to be the only way to have the attack animation play till the end before going back to idle
@easyU2B
@easyU2B 4 года назад
Whoa! This is really powerful...! Thanks for the tutorial.
@jackspade6401
@jackspade6401 5 лет назад
Dude! Thank you! Keep up the awesome videos!
@tayete
@tayete 4 года назад
Great tutorial: really clear and well explained.
@jckelleri
@jckelleri 2 года назад
I didn't even know this was possible, it was very helpful, and I learned a lot thank you.
@MattRandall160
@MattRandall160 4 года назад
Some really awesome and useful videos!! thank you
@TackerTacker
@TackerTacker 5 лет назад
Great video and I love the Godot recipes website
@awiggan1
@awiggan1 5 лет назад
These little recipes are really good. Very handy
@suvigyamishra4604
@suvigyamishra4604 3 года назад
i was checking on the gdquest professional game development course.. and reaching to just this part was so overwhelming.. not saying that the course was bad.. but see this is all it takes to understand how states work.. Great Video!
@ArkOfAges
@ArkOfAges 5 лет назад
Really interesting. Thank you for posting.
@ducanhtran8929
@ducanhtran8929 5 лет назад
Love your videos! Keep it up
@PeterKLee
@PeterKLee 4 года назад
thank you for sharing your knowledge! It was greatly helpful to me :)
@fossegutten6579
@fossegutten6579 5 лет назад
Nice video! Love the website aswell.
@markyap3865
@markyap3865 4 года назад
great video man. Thanks for the help!
@josuereis6367
@josuereis6367 4 года назад
Awesome! Thank you!
@spiritabsolute
@spiritabsolute 4 года назад
Thank you very much dude, you really helped me!
@diegoh473
@diegoh473 Месяц назад
thanks this is what I was looking for!
@ChavsberryGaming
@ChavsberryGaming 4 года назад
Absolute unit.
@McHumaty
@McHumaty 5 лет назад
Nice work.
@MarvelousLXVII
@MarvelousLXVII 3 года назад
Really nice video.
@pranavkul525
@pranavkul525 3 года назад
That helped me a lot. Thanks!
@flowfrog101
@flowfrog101 Год назад
Thank you so much i was really struggling with the animation tree
@omaryahia
@omaryahia 7 месяцев назад
amazing🌟
@mohamedSGH420
@mohamedSGH420 Год назад
Thank so much bro your a life saver
@lucaspec7284
@lucaspec7284 4 года назад
this was very helpful, thanks
@luisv1308
@luisv1308 5 лет назад
Thank you!
@MarcLdhl
@MarcLdhl 5 лет назад
Awesome!
@StrikeKINGyt
@StrikeKINGyt 5 лет назад
awesome, thanks man!
@robertnett9793
@robertnett9793 2 года назад
Well.. that solves problems. Soooo many problems. Thanks a lot mate :D
@johnhammer8668
@johnhammer8668 4 года назад
mind blown !!
@Garniy_Hlopchik
@Garniy_Hlopchik 8 месяцев назад
"and than there's die, when we reach that state there is no return" went dark all of a sudden lmao
@yapayzeka
@yapayzeka 5 лет назад
lovely
@samuelallen6494
@samuelallen6494 4 года назад
i have been using this method: func _physics_process(delta): |> if Input.is_action_pressed("ui_right"): |> |> vel.x = speed |> |> $animation.play("walk") ------------------------------------------------------------------ this is a good way to do it but it has limitation like sliding before going into idle is not possible in this method
@johnpark3243
@johnpark3243 5 лет назад
Great video to see after hand crafting a complex animation state function that's tightly integrated into all of my scripts... :( lol gonna have a go at tearing down and rebuilding all of my animation code now, see you guys in 5 hours
@1nopinate
@1nopinate 2 года назад
how was the 2 years and 5 hours goes ?
@ennizodev
@ennizodev 2 года назад
It's shown on my RU-vid, this is a great opportunity.
@harveyg2147
@harveyg2147 4 года назад
I have four idle animation {right,left,up,down} and don't know how connect them each other
@hessaa1712
@hessaa1712 4 года назад
thats very good video
@pixelrabbit261
@pixelrabbit261 4 года назад
Great video! I just watched a bunch of other "state machine" videos which just use code (enum). Is this doing exactly the same thing but saving us having to write as muchcode for each state?... when would you use code rather than an animation tree. Pixel Gamemaker relied heavily on this tree approach. I gave up in the end and decide to learn to code :)
@Kidscancode
@Kidscancode 4 года назад
Those videos are talking about a generalized state machine for your character, which can handle any aspects of its behavior. This is specifically an *animation* state machine.
@fanimation2000
@fanimation2000 4 года назад
THAT WAS VERH HELPFUL TNX A LOT ^_^
@nickbubuioc
@nickbubuioc 3 года назад
i love your tutorials , they are short and right to the point , i have a question , im trying to make top down rpg , and i have idleRight,Left,Up,Down , how can i set this up ? :) Thank you for the amazing work
@martinmajewski
@martinmajewski 5 лет назад
It is possible to make a double-attack by checking the current animation state and transition to the second attack only if the first attack's animation is still playing? Moreover, it would be nice to read the current timestamp of the animation. In this case, the physical length of the animation an/or time range during the animation's play would make an excellent condition to perform combo-attacks by hitting the same input action (button) multiple times in the correct time-distances.
@carismicaids7614
@carismicaids7614 2 года назад
i was missing one word for my code to work, if i had not found this video i may have lost inspiration to continue the creation of my game. Thanks!
@Petoj87
@Petoj87 4 года назад
Is there some tutorial where you go over how you setup the animations in the animation player? your animation is in sync with the line, mine just starts when i hit play, and continues even if i pause..
@AkaiKnight
@AkaiKnight 3 года назад
*flashback to unity mecanim* oh god I dont wanna go back
@annoyed567
@annoyed567 3 года назад
var current = state_machine.get_current_node() is an invalid call non existent function "get _current_node" in Base NIL also the var current variable is never used so i tried experimenting and removing the line completely, perhaps i dont understand state machines. with out a var current line of code it then seems to bring up a error on state_machine.travel("idle"), right at the end of get input. if i replace this with return the game then loads, but any action or input that requires it to use the .travel function breaks the game and come up with another non existant function "travel" which was the same error the idle arror had. can anyone explain this,
@ChavsberryGaming
@ChavsberryGaming 4 года назад
Oh thanks a lot. So many things to screw up.
@mleitejunior
@mleitejunior Месяц назад
I know the focus of the video it is the AnimationTree (an Animation State Machine), but would not be perfect to align it with a player state machine, instead of all ifs in process? Something like a node/script and subnodes/subscripts to handle all the logic and attributes of the player in each state. You can par it with the animation state machine and everything would be organized and easy to grow with no big problems.
@josesena4314
@josesena4314 5 лет назад
Your videos are so great. I have a newborn child and I can't wait until she get the age of learning how to code. Your channel will be so helpful
@pattyorigami
@pattyorigami 4 года назад
Any possibility you could do another video on this showing how to implement it with 2d platformers? I'm having a lot of trouble getting jumping and falling animations to work smoothly this with animation states
@Warionator
@Warionator 4 года назад
in your code, if the player y velocity is negative (they are going up), then play the jump, if the y velocity is positive (they are falling), play the falling animation
@grandromusic683
@grandromusic683 5 лет назад
Nice video, it helped me alot :) But I think one detail needs to be added which I found out having troubles with the AnimationNodeStateMachine: Its better to check if the state_machine is playing before you travel to a node, because otherwise you could get an error if the state machine is not active. You do that simply by checking: if state_machine.is_playing(): before you use the travel function. This becomes definetly necessary if you work with sub state machines, as they wont get activated at the beginning.
@Kidscancode
@Kidscancode 5 лет назад
Yes, I noticed your issue about this.
@fastfading4667
@fastfading4667 5 лет назад
could u share the project file ? it will be helpful
@robby2725
@robby2725 5 лет назад
I love you ❤️
@ivanmectin9106
@ivanmectin9106 2 года назад
for the two attacks , he does a return, does that mean it returns to idle ?
@Nipah.Auauau
@Nipah.Auauau 5 лет назад
low volume :/
@gargoyled_drake
@gargoyled_drake 2 года назад
for some reason this didnt work for me, i havent added the attack yet, but just the travel from idle to run and such dosnt work, my character is just stuck in a still frame after adding this. animation player worked fine though, but this seem to be the only way to play a full animation and go back to idle state when button is pressed
@jasonwilliams8730
@jasonwilliams8730 7 месяцев назад
I see start and end but what about an anystate?
@bubblemage
@bubblemage Год назад
So how would you make it so the double attack is not automatic, but instead you can press the attack button twice to first make attack1 and then attack2? like a combo attack
@gargoyled_drake
@gargoyled_drake 2 года назад
wait what ? so i need to use the animation player ..... only spend all day setting this up with the animatedsprite 😢
@HeraldOD
@HeraldOD 4 года назад
How do I detect when the death animation is finished (to reload the scene for example)? With AnimationPlayer I just used the animation_finished signal, but it doesn't work with the state machine, and there's no signal on the AnimationTree.
@adhityarisyad9029
@adhityarisyad9029 4 года назад
is there anyway to stop running and finish the attack animation when you pressed attack while running?
@muajin
@muajin 4 года назад
Hello. I'm in a similar bind. I have the script with animations but either i'm missing a line or have one misplaced. My player moves but only one animation works and doesn't change direction.
@tohut5507
@tohut5507 3 года назад
How do I make the animation playing smooth of the walk, sometimes the animation plays and other times it does not play ? How do I fix it ?
@nbourre
@nbourre 2 года назад
I have the same problem. The walk animation goes back to idle even if I don't tell the code to travel to "idle". This occurs with an enemy I'm trying to implement.
@teambeluga1934
@teambeluga1934 4 года назад
Good video, but this setup will only work for a very simple character. An involved complicated enemy with AI and the like, I'm still not certain how this will help. Especialyl with areahit boxes and the like. Perhaps I need to think about it more.
@motizukilucas
@motizukilucas Год назад
During IDLE it stay stuck at idle left regardless if I've moved right or up before
@nowherebrain
@nowherebrain 4 года назад
Looking for a video on AnimationTree usage in GDscript, but everyone seems to be covering state machines that can be done easily with a switch case(match)...could you do one that covers accessing animation nodes inside an animation tree...like changing the "add" animation from a one shot...this is one of the things I am fighting with.
@Kidscancode
@Kidscancode 4 года назад
Thanks for the suggestion. I put it on my (unfortunately very long) list! :)
@jovlem
@jovlem 4 года назад
For me, the "statemachine.travel("animation_name") is not working. Any idea what could be wrong? ( I use stable version 3.21 )
@MarvelousLXVII
@MarvelousLXVII 3 года назад
state_machine perhaps?
@Dejawolfs
@Dejawolfs 9 месяцев назад
they must have changed this in 4.0, since i get an error "null"
@Riodragon1
@Riodragon1 5 лет назад
you are a god thx , you could made one tutorial rhythm games?? I do not encounter anything about it /=
@kenet206
@kenet206 4 года назад
DAYS BYGONE?!
@9livesK9
@9livesK9 2 года назад
Its also possible to use an AnimatedSprite node and then key in the frames into an animatedPlayer then use the animationTree to control the state machine "AnimatedNodeStateMachineTransitions"? Or does this just only work with Sprite? Sorry if this is a silly question. I'm a beginner in Godot. Why I'm asking is because I already have my SpriteFrames loaded up in one AnimatedSprite and I don't want to start all over again and re-import everything if its not necessary (if AniatedSprite and Sprite are similar enough).
@Kidscancode
@Kidscancode 2 года назад
AnimatedSprite can only change textures. In this example we are also moving and enabling/disabling collision shapes. You need AnimationPlayer to do that.
@gendalfgray7889
@gendalfgray7889 4 года назад
Hello. I'm making fps with godot tutorial. In it animation state tree is not used, states and changin process writed in code. I managed to simplify tutorial code for animation changing to single structure. Guns in tutorial have 5 animations, idle, equip, unequip, fire, reload. In my piece of code i can add weapon with another name but with same 5 animations without changing the code. Is it possible to make such universal structure in animation tree? Because for every new weapon i need to add 5 more animations in to tree. And i want lots of weapons. Animation tree is convenient and have blends, which i want to use too.
@boratsagdiyev1586
@boratsagdiyev1586 4 года назад
I guess i'm going back to IF statements, because my spritesheet of run jump walk run attack are all on separate spritesheets. Making that work is worse than anything... I cant put 2 sprites on 1 animation player so eventually it's even more clutter. Back to learning GDscript >< My animation only stops walking when i move to the right while holding jump
@7_rlz_714
@7_rlz_714 4 года назад
Same problem, I have separate Sprite action, i can't add two action in one spritenode, because are in top or behind between them
@Kidscancode
@Kidscancode 4 года назад
> " I cant put 2 sprites on 1 animation player" Sure you can. AnimationPlayer can control *any* property, including the Sprite's *Texture*.
@boratsagdiyev1586
@boratsagdiyev1586 4 года назад
@@Kidscancode but i need animatedSprite not the normal sprite , still possible?
@awesomehazimex7410
@awesomehazimex7410 4 года назад
@@boratsagdiyev1586 yes animated sprite and animation player can be used together
@fernanboxfrias381
@fernanboxfrias381 3 года назад
How did you change the color of the letter of your script
@brucelee7782
@brucelee7782 9 месяцев назад
does this work for cutout animation? Im using bones and ik and rotating the sprites around
@wash99
@wash99 3 года назад
How can I add Jumb and dash
@rikzander8691
@rikzander8691 4 года назад
Hello, Is it possible to play animations backward in the state machine?
@martinpellicer8489
@martinpellicer8489 4 года назад
hey please help me,I searched in every place and noboady answer me. its works all perfect for me except that when I try to go from "shooting" animation to "idle" at the end, it dosen´t work, "Fire" play very very fast and then "idle" play. Both have the same conditions because my "idle" animation play when velocity is 0 and is_on_floor, and my "Fire" animation too, because I want that you can´t move when you are shooting. I think it is because of when I select in animation tree "at end" it dosen´t work. Shooting on the condition has the key you have to press to shoot, so it enters and change from "idle" to "fire" but then very fast to "idle" again
@flyssa8211
@flyssa8211 3 года назад
que grande
@TheTattorack
@TheTattorack 4 года назад
This doesn't work for me at all. I've followed JayAnAm's tutorial on 3D character movement and it's fine, but I want to add some in between animations for when, say, the character lands on the floor. State Machine can apparently do that, and this is the only well made tutorial for animation state machines, but "var current = state_machine.get_current_node()" throws an error, something about it not existing.
@MoogieSRO
@MoogieSRO 3 года назад
I just encountered this and fixed it. Firstly, check that you didn't capitalize the "parameters/playback" bit. Then make sure you have set a 'start' and 'end' state in the animation player with those two little flag buttons you see next to the trash button. You might run into additional difficulties if you don't have an 'idle' animation (like I don't) but we should be able to figure that part out for ourselves. Hope this advice didn't come too late!
@Duraznito9712
@Duraznito9712 3 года назад
What if I want to have four aditional animations for diagonal movements? How could I program it?
@jovlem
@jovlem 3 года назад
When I use: $Animationtree.get("parameters/playback").travel("attack1") it won't work, why is that?
@yurihoe1033
@yurihoe1033 3 года назад
is it in func _ready ?
@cedricleclercq3601
@cedricleclercq3601 5 лет назад
Hi, How can i reverse the position when my character is attacking in a another way?
@smutnywalen
@smutnywalen 4 года назад
$AnimatedSprite.flip_h = true
@mrlonelyFilms
@mrlonelyFilms 4 года назад
@@smutnywalen Yeah but that only flips the sprite not the hitbox....
@boratsagdiyev1586
@boratsagdiyev1586 4 года назад
Edit: removed question and figured it out.
@mrmixedvideomaker9767
@mrmixedvideomaker9767 4 года назад
Hi I am trying to make a platformer and this worked, but the animation speed is too low, so how do I increase the speed?
@danobra
@danobra 3 года назад
What are transition nodes for? It seems you don't use them and some other devs do
@pow4570
@pow4570 2 года назад
I cant active animation tree. 1:53 can someone help?
@cris3758
@cris3758 2 года назад
I just don't get way you would ever use something like this. I feel like it all falls apart when you start creating the hurt() and die() functions: you could just as well recall the "hurt" and "die" animations directly from the AnimationPlayer. The only situations I can think of that's easier to handle with the AnimationTree is when you want to concat animations, like when you combo Attack 1 into Attack 2
@abylaikhanjulmagambetov4364
@abylaikhanjulmagambetov4364 2 года назад
I believe the animation tree is for handling the transitions between animations (immediate, etc.) and as author mentioned keeps the code cleaner from a bunch of if statements
@spachurrenGuias
@spachurrenGuias 4 года назад
I have one strange problem when trying to turn the kinematicbody2d scale: if Input.get_action_strength("ui_right"): input_dir += 1 self.scale.x = 1 if Input.get_action_strength("ui_left"): input_dir -= 1 self.scale.x = -1 But when pressing them it does "blink" and has both left and right looking elements (my animation is build with 1 node with sprite each per element... hand, feet, body, head...) and while "blinking" it does get out of collision with ground and fall down...
@spachurrenGuias
@spachurrenGuias 4 года назад
Problem solver, avoiding scale, appart from having stuff at the positive range of X axys that when scaled goes auto into negative one which causes clunky animation, it does blink even when fixing it. Finally used a node group to set_flip_h among the whole group and "et voila"
@Nugget11578
@Nugget11578 4 года назад
is there a way to blend the animations while also having this state tree?
@ryoneer
@ryoneer 4 года назад
click on the arrowed line between nodes, and play with the Xfade time, it smoothens it nicely
@AxlCake
@AxlCake 4 года назад
He sets a var for get_current_node() but never uses it, could anybody tell me what that is for exactly and why it needs to be there?
@sherekhangamedev
@sherekhangamedev 4 года назад
I have the same question.
@freshouttathebag7725
@freshouttathebag7725 Год назад
what does the sync transition do?
@lockingsalt
@lockingsalt Год назад
How do you implement this on godot 4?
@yolamontalvan9502
@yolamontalvan9502 4 года назад
I hope this is not like Coco2d that was supposed to be the greatest thing to be used with swift and Xamarin.
@adamsmiddy
@adamsmiddy 5 лет назад
What is velocity.length? Why not just use velocity.x == 0 or something similar?
@GameEndeavor
@GameEndeavor 5 лет назад
Because it's a top down game not a platformer. If there is any movement in a top-down game, then you want to transition to the run state.
Далее
Godot Recipes: Melee Attack
5:19
Просмотров 107 тыс.
Godot 3: Finite State Machine Code Example Overview
11:41
▼ЕГО БОЯЛИСЬ МОНГОЛЫ 🍣
32:51
Просмотров 368 тыс.
Minecraft Pizza Mods
00:18
Просмотров 1,5 млн
Pygame Tutorial #3 - Character Animation & Sprites
15:49
Godot 3.0: 2D Visibility with Ray-casting
22:22
Просмотров 69 тыс.
Godot Shader Tutorial (1): Intro to Shader Programming
23:09
Starter state machines in Godot 4
10:58
Просмотров 41 тыс.
[Tutorial] Como fazer animação no Aseprite
14:55
Просмотров 32 тыс.
6 Tips to Better Organize your Godot Projects
11:39
Просмотров 133 тыс.
▼ЕГО БОЯЛИСЬ МОНГОЛЫ 🍣
32:51
Просмотров 368 тыс.