Тёмный

Add Random "Bored" Idle Animations to Your Character (Unity Tutorial) 

Ketra Games
Подписаться 23 тыс.
Просмотров 29 тыс.
50% 1

In this Unity game development tutorial we're to going look at how we can add a bit more personality to a character, by playing random "Bored" animations after they’ve been left idle for a period of time.
We'll start by downloading several animations to play when the character becomes bored.
We'll then look at how to use a Blend Tree combined with a State Machine Behaviour Script, to transition to these animations at random after a period of idle time.
The project files are available to our patrons here:
► / 65535482
Want to follow along? This project is a good starting point
► / 62683553
The full script for this tutorial can be found here
► dotnetfiddle.net/ANF7BZ
Help support our work:
► Patreon: / ketragames
► Ko-fi: ko-fi.com/ketragames
Follow us:
► Ketra Games: www.ketra-games.com
► Patreon: / ketragames
► Twitter: / ketragames
► Facebook: / ketragames
Introduction - 0:00
Getting Bored Character Animations from Mixamo - 00:41
Configuring the Bored Idle Animations - 2:18
Setting up the Idle Blend Tree - 3:43
Adding a State Machine Behaviour Script to Randomly Select a Bored Animation - 5:58
Improving the Transitions between Idle Animations - 10:36
Summary - 14:59
#KetraGames #LearnUnity #UnityTutorials #UnityTips

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

 

21 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 76   
@JeremiahT
@JeremiahT 2 года назад
I really appreciate how you didn't just show the final solution but the entire iteration process. I think the information sinks in better that way.
@KetraGames
@KetraGames 2 года назад
Great to hear this, thanks 😊
@dangravel2451
@dangravel2451 2 года назад
Thanks a lot for this! Everywhere I read about blending animations told me "you need to setup your blend tree, and write a script"... Gee, thanks.. We all have things we're good at, and others not so much, this aspect I hadn't a clue how to set up. Liked, subscribed.
@rachapongwatana3868
@rachapongwatana3868 Год назад
Thank you so much for sharing how to play with NPC Behavior with some random animation, Awesome tutorial !
@JermsKylefilms
@JermsKylefilms 4 месяца назад
love this video so much, not ashamed to say ive forget like 3 times and had to come back but thanks for this lol.
@hefferwolff3578
@hefferwolff3578 2 года назад
This was so good, thanks so much!
@KetraGames
@KetraGames 2 года назад
Thanks, glad it was useful 😊
@lorddawn3752
@lorddawn3752 Год назад
Damn that's impressive with each step explained. This should be a go-to tutorial for anyone using mecanim.
@KetraGames
@KetraGames Год назад
Thank you 😊
@evil_beast_z
@evil_beast_z Год назад
ur Hi guys gives me a relief
@evanlegrand874
@evanlegrand874 Год назад
Such an awesome tutorial, thanks!
@KetraGames
@KetraGames Год назад
Thanks very much for this comment 😊
@donpapamendez2352
@donpapamendez2352 Год назад
Thanks for the tutorial, you are too good. you have a new subscriber
@KetraGames
@KetraGames Год назад
Thanks for your support 😊
@ObiWineKenobi
@ObiWineKenobi 6 месяцев назад
Thank you! This worked great!
@KetraGames
@KetraGames 5 месяцев назад
Great to hear, thanks 😊
@MickyMiniAdventures
@MickyMiniAdventures Год назад
Thank you for your awesome tutorials. Your tutorials are very clean and easily understandable it's saves a lot of time. You are an inspiration to the female developers
@Tenzordk
@Tenzordk 2 года назад
And my enemy's idle is done! - Thanks! :D
@KetraGames
@KetraGames 2 года назад
Great 👍😊
@ani-gamer320
@ani-gamer320 2 года назад
Thanks again ❤️❤️❤️
@KetraGames
@KetraGames 2 года назад
👍😊
@MVAgustaBrutale1000RR
@MVAgustaBrutale1000RR 8 месяцев назад
You are the best override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { int randomClip = Random.Range(1,4); animator.SetFloat("Rise",randomClip); }
Год назад
Just best animation tree tutorial on YT, I wish Narasimha bless your life and protect your family!
@KetraGames
@KetraGames Год назад
Thanks for this comment
@amcmahon134
@amcmahon134 2 года назад
Hi, this tutorial series has been super well done and helpful! Are you planning to cover water/swimming at some point in the future?
@KetraGames
@KetraGames 2 года назад
Thanks. Yes, water, swimming and diving are on our list for future videos.
@seyfo.03
@seyfo.03 10 месяцев назад
It works very well, just the last animation will play on loop for a couple times. I don't understand why, any ideas?
@IslamAudioStation
@IslamAudioStation Год назад
not the easiet method but it works. well done.
@KetraGames
@KetraGames Год назад
In hindsight, this maybe wasn't the easiest approach. Perhaps a Direct Blend tree would have worked better. One to revisit in future 😊
@combobreaker9618
@combobreaker9618 9 месяцев назад
It works for me, but the counter on the float parameter "Bored Animation" keeps going down till values like -1.662e-44, and I can't get it to round 0. Any idea on what's causing that?
@K3NZ
@K3NZ 11 месяцев назад
The stateInfo Normalized time is going up more than 1, what to do to fix the problem ?
@pushingpandas6479
@pushingpandas6479 2 года назад
this character is sooo cute
@KetraGames
@KetraGames 2 года назад
😄😄
@hmbullen
@hmbullen Год назад
Thanks for the tutorial! Could you use a 2D freeform blend tree rather than the 1D? Avoid having the multiple idle states in the blend tree to revert back too...
@KetraGames
@KetraGames Год назад
Hi, thanks for the suggestion. A 2d blend tree may work better or perhaps a direct blend tree 🤔. We'll have a play and may do a version two of this video if we find anything better
@ivyxu5222
@ivyxu5222 Год назад
Hi, thank you so much for making this video! I'm using this approach on a 2D animation. There are two idle animations, and there isn't the need for blending. However, when I set the waitTime to 5 or 6 seconds, the trigggered idle animations never play from the start or play till the end -- there are always some frames cut off. I have a feeling it has to do with the normalizedTime comparison, but I don't know how to fix this. Any hints or leads on this?
@krawper
@krawper Год назад
Same problem as you, for a 2D character. I've been trying to find a solution since yesterday to fix this error, but it's difficult.
@ivyxu5222
@ivyxu5222 Год назад
@@krawper my work around was to set the waitTime to 6s, which for me had the minimal cut off, and then extended the beginning of one idle animation with extra blank frames so the important part doesn’t get removed
@zachwang6156
@zachwang6156 Год назад
Love the tutorial! I followed the steps exactly but when I finished with the coding aspect and went into Unity to change the "Time Until Bored" I don't have the option to and instead there's an error message reading "Please fix compile errors before creating new state machine behaviours". What does that mean and how can I move forward?
@KetraGames
@KetraGames Год назад
Hi, are there any errors in the console window?
@forcepower7116
@forcepower7116 2 года назад
Hey, so sometimes when stopping to move it plays one of the bored animations. Is that supposed to be ? Because I thought it would only play them after we are idle for long enough
@KetraGames
@KetraGames 2 года назад
Hi, it shouldn't go straight into a bored animation. We ran into this problem when we were doing some testing for this video, and the problem was the order of the animations in the Blend Tree. Check that you have them in the following order. Breathing Idle, Bored, Breathing Idle, Shuffling, Breathing Idle, Offensive Idle. Hope that helps 😊
@jussirautiainen7772
@jussirautiainen7772 Год назад
This set up does not work ... if I use my own animations then the stateInfo.normalizedTime starts counting at 0.75 and never at 0 ... so the transitions play for a split second and return to the 0 state ...
@marhirari
@marhirari Год назад
i'm already using a blend tree for idle, walk and run animation, how do i connect this one to the old one?
@KetraGames
@KetraGames Год назад
Hi, you would connect the two blend trees with a Transition that goes from the idle blend tree to the movement one when there is movement input and then another transition that goes back again when there is no input. Hope that helps 😊
@nikobellic7455
@nikobellic7455 2 года назад
Why not use a sub-state machine? I have used animation sub-state for things like that and it was super easy to implement. Unless I am unaware of the benefits of using blend tree for this use case.
@KetraGames
@KetraGames 2 года назад
Hi, we originally thought that a sub-state machine would be the way to go with this as well. When we started to explore this though, there doesn't seem to be a way to transition from any state in the sub-state back to a state in the base layer. So you have to add a transition from every idle animation in the sub state to Jump in the base layer and to Move in the base layer. If you were to add other states from Idle such as Crouch, Pull Lever, etc. then you would have to duplicate these transitions as well. By using a Blend Tree we only have one state for Idle so we only have to set up and maintain one set of transitions. If you've found an easier way to do this using a sub-state machine then it would be really great to hear how you did it 😊
@nikobellic7455
@nikobellic7455 2 года назад
@@KetraGames I see your point now. My project was fairly small, so I didn't have many transitions from idle. Thanks for your tutorial, learned something new.
@you_what319
@you_what319 Год назад
Curious, I've taken the +1 out of the Random.Range, changed numberOfBoredAnimations to numberOfIdleAnimations and set that to 4 in the inspector, this way makes more sense to me and has the same results. Is their anything wrong with this method that I don't see? Thanks again for another brilliant tutorial.
@KetraGames
@KetraGames Год назад
Hi, that should work just fine. Whichever way makes the most sense to you 😊
@you_what319
@you_what319 Год назад
Thankyou Ketra, so far so good, I've not long finished this series and have gained a wealth of knowledge and have a solid starting point for my new Project. Much appreciated. Your style is so much easier to follow along.
@yaxees349
@yaxees349 2 года назад
hi, when enemy tutorial?
@KetraGames
@KetraGames 2 года назад
Hi, we're hoping to start looking at enemy AI soon 😊
@ColtPtrHun
@ColtPtrHun 2 года назад
In my understanding, blendtree is for mixing animation clips, not select one of them. I think a Sub-State Machine (or a new animation layer maybe) would be a better fit.
@KetraGames
@KetraGames 2 года назад
Hi, you're absolutely correct in that this isn't the intended use case for a blend tree. We tried using a sub state machine first but you can't transition from any state in the sub state machine, so you end up having to add transitions from every bored animation and it becomes difficult to manage. Layers might be a better way to go though. We'll have a play and possibly redo this video if we find a better way 😊
@ColtPtrHun
@ColtPtrHun Год назад
@@KetraGames I see, you're right.. Since then I ran into the same problem with subtrees. I was thinking about using an empty state which would gather the transitions, and go to idle states from there, but that may would mess up the transitions.
@ColtPtrHun
@ColtPtrHun Год назад
@@KetraGames Also, moving these animations to a new layer feels a bit awkward, since these animations belongs to the same layer and what if I want to use custom transitions to-and-from the blendtree etc... It seems like blendtree is the way to go! Thank you for your answer 🙂
@KetraGames
@KetraGames Год назад
@@ColtPtrHun Hi, we've thought of some other options since that may be easier that you may want to try. A direct blend tree might be able to get past some of the complication brought about by using the 1D blend tree. Another option, which is probably the easiest depending on how your scripts are set up, would be to switch animation states in the scripts rather than using the transition states in the animator, using docs.unity3d.com/ScriptReference/Animator.CrossFadeInFixedTime.html
@DenysAlmaral
@DenysAlmaral 11 месяцев назад
@@KetraGames CrossFade is the way
@onursevinc6840
@onursevinc6840 Год назад
🔥🔥🔥
@KetraGames
@KetraGames Год назад
👍😊
@bunzy5279
@bunzy5279 2 года назад
Could you also do on player input, end bored?
@KetraGames
@KetraGames 2 года назад
Hi, if you start moving the animation will switch to running. Do you mean for other input?
@bunzy5279
@bunzy5279 2 года назад
@@KetraGames I was thinking along the lines of idle timer into an idle animation (say a sleep) then it wont change the new idle animation until we receive player input. If you've played hollow knight its like how the bench idle animation plays if that makes any sense.
@KetraGames
@KetraGames Год назад
@@bunzy5279 Ah, I see what you mean. Yes you could do a similar thing but just don't revert back to the original idle animation
@zendraw3468
@zendraw3468 2 года назад
why dont you make a discord server
@khnuxsora
@khnuxsora Год назад
Hey, can I use this in a 2D game?
@KetraGames
@KetraGames Год назад
Hi, you should be able to use the same principle in a 2D game 😊
@khnuxsora
@khnuxsora Год назад
@@KetraGames Thank you for the reply! 😄
@deathstroke2877
@deathstroke2877 2 года назад
I need help xD. My player has autismus now.
@KetraGames
@KetraGames 2 года назад
Hi, what's going wrong? The full script is available here so you can compare with what you have - dotnetfiddle.net/ANF7BZ. I'd also check that the animations are in the correct order in the blend tree and have the correct thresholds. Hope that helps 😊
@deathstroke2877
@deathstroke2877 2 года назад
@@KetraGames My idle animation playtime is too short, i guess.
@PranjayMittal
@PranjayMittal 2 года назад
Thanks. Im using unreal but I couldn't figure out how to actually do it
@bobdawkins7473
@bobdawkins7473 5 месяцев назад
Wouldn't recommend this method in real (Depending on what your game is) because you'd want to use layering. This method is hard 1 to 1 and can't be called from other states in this setup.
@darrylswims8721
@darrylswims8721 2 года назад
😏 ᴘʀᴏᴍᴏsᴍ
@486x
@486x Год назад
totally USELESS
Далее
Improving Ragdoll Physics (Unity Tutorial)
12:48
Просмотров 10 тыс.
Escaping Unity Animator HELL
18:18
Просмотров 500 тыс.
Победитель евровидения
00:18
Просмотров 20 тыс.
We will see who will do it better 😂
00:14
Просмотров 3,5 млн
Animation Retargeting (Unity Tutorial)
10:34
Просмотров 47 тыс.
How to play random animations [Unity Tutorial]
7:36
Просмотров 21 тыс.
I coded your HORRIBLE Minecraft ideas
15:11
Просмотров 273 тыс.
10 Minutes vs. 10 Years of Animation
19:29
Просмотров 698 тыс.
Injured Animations using Layers (Unity Tutorial)
13:43
Complex Animations made Simple with Blend Trees!
12:06