How to change your Animators Animation clips at runtime in Unity3D

Поделиться
HTML-код
  • Опубликовано: 19 апр 2020
  • In this #unity3D video, ill be showing you how to change the animation clips of your animator's states so that you can use the same parameters and links for different animations!
    To talk more about Unity3D and #GameDev or any of my other #tutorials you can join my discord at:
    / discord
    ********************************************************************
    ● Support me with Brave: brave.com/cod828
    ♥ Subscribe: bit.ly/2FRWgOi
    ● Facebook: bit.ly/2DhBC6I
    ● Twitter: / indie_unleashed
    ********************************************************************
    ● Make a Grid with a 1-dimensional array: bit.ly/2sRTpfL
    ● How to make Snake in Unity Tiny: bit.ly/2UmJHhe
    ● Climbing System Show off: bit.ly/2FPurq1
    ********************************************************************
    ● Unity3D Animator Override Controllers manual:
    docs.unity3d.com/Manual/Anima...

Комментарии • 71

  • @willycampos6101
    @willycampos6101 4 года назад +13

    Nice content, instead of passing the int index, you can pass on the actual animator controller override as parameter. On button press (change stance).
    No need to use the array of overrides.
    XD

    • @CodingWithUnity
      @CodingWithUnity  4 года назад +1

      oh cool, i guess i could of tried that, i just assumed it wouldnt serialize it out to pass through the unityEvent :D

  • @Yenrei
    @Yenrei 3 года назад +2

    A video on exactly what my design was imminently going to end up needing? Cleanly executed and easily implementable in future scenarios? Yes please.

  • @NPCsz
    @NPCsz 3 года назад

    This is what I'm looking for about two weeks, thanks !!!

  • @LaurenceCreates
    @LaurenceCreates 4 года назад +6

    An easy implementation and cleans up alot of the mess when it comes to animating using just 1 animation controller.
    Good job. love the work!

    • @CodingWithUnity
      @CodingWithUnity  4 года назад +1

      Appreciate it!
      It can be super useful for a lot of stuff.
      Works for swapping sprites out on 2D games also

  • @MrJeenabanta
    @MrJeenabanta Год назад +1

    Thank you for the clear example. Was googling the answer, to change the Animator controller during run time. Your solution was more helpful and concise.

  • @matthewbennett8510
    @matthewbennett8510 Год назад

    This was amazing! I have been so close to getting this to work and you just nailed it for me! Thank you!!!

  • @MrMariy0
    @MrMariy0 2 года назад

    exactly what i needed :)
    thank you, it's working like a charm!

  • @bryanirvine3914
    @bryanirvine3914 3 года назад +6

    This is immensely useful! No joke, my animator state machines looked exactly like the picture you shared at 0:13. Never again stuck in animator hell. THANK YOU!

  • @blah2758
    @blah2758 3 года назад

    amazing, this example was just what I needed thanks

  • @adamcourtney8255
    @adamcourtney8255 2 года назад

    I learned lots! :) Thank you - hopefully I'll be able to make something neat with this approach

  • @DavidZobristGames
    @DavidZobristGames 2 года назад

    This is such mandatory knowledge which I did not have after 2 years with unity..Thanks

  • @danielnnadi6614
    @danielnnadi6614 Год назад +1

    This totally saved my life

  • @ondrejpolcar2872
    @ondrejpolcar2872 10 месяцев назад

    Discovering this video saved me a lot of future pain. Thanks you sir.

  • @reendevelops
    @reendevelops 2 года назад

    This will greatly help with my equipping system!

  • @fulgencejuniorlohore854
    @fulgencejuniorlohore854 11 месяцев назад

    Thanks buddy, you helped me out! 2023 and still relevant!

  • @JongHyunSM
    @JongHyunSM 3 года назад

    Thankyou so much!!, I'm looking for this tutorial !!!!

  • @peterschreuderr
    @peterschreuderr 2 года назад

    Thank you!!

  • @entertainmentoverloaded5700
    @entertainmentoverloaded5700 2 года назад

    Fantastic video :)

  • @GameDevBryant
    @GameDevBryant 2 года назад

    Thanks, this is really hepful!

  • @abassianis9237
    @abassianis9237 4 года назад

    Great Video Thank you

  • @MesaTheAalfa
    @MesaTheAalfa 4 года назад

    Thank You So Much !!! I was working for days how to animate my 2D Sprite sheet left side & right side character sense it has asymmetrical sides .. I thought that I can manage to do it through Layers but it was getting overly complicated , then I just learned about animator override today !! T^T

  • @GianniPapetti
    @GianniPapetti 4 года назад

    I want to do a game where you can choose wich attacks you can do with a card system, and this video saved me an animator with more than a hundred states

  • @lukastomasek8038
    @lukastomasek8038 4 года назад

    Great tutorial !

  • @ezydenias8505
    @ezydenias8505 2 года назад

    crazy how many people switched to rider.^^ God choice. Also thanks this tutorial helped me allot.

  • @jean-michel.houbre
    @jean-michel.houbre 2 года назад

    Good evening, I was familiar with the use of the AnimatorOverrideController in the case of a character with different weapons, involving the script modification of the clip of several AnimatorStates, but this use to lighten the graphs is very elegant. Thank you.

  • @Ne0mega
    @Ne0mega 3 года назад

    Thanks doot! Huge problem now solved!

    • @Ne0mega
      @Ne0mega 3 года назад

      ugh, nevermind... this doesn't help when there are layers. Looks like animator.Play(string state, int layer) is going to be my solution.

  • @naftalilipman8153
    @naftalilipman8153 3 года назад +2

    This is great, thank you.
    Is there a way to make the transition between idle states a bit more smooth?

  • @FaeranJourneys
    @FaeranJourneys 4 года назад +2

    You Rocks! men!

  • @a.technology1446
    @a.technology1446 4 года назад

    Amazing

  • @465Davide
    @465Davide 3 года назад

    thank you for this tutorial. There is a way to smooth the transition detween the override controllers?

  • @FreakyStudios
    @FreakyStudios 4 года назад

    Hello bro how can i disable the animator controller override !

  • @grftaNitro
    @grftaNitro 4 года назад +2

    Great video! Is it possible that you could make a tutorial on procedural animation, inverse kinematics (Or whatever it's called) in the future? I'd be interested in the mechanics behind that!

    • @CodingWithUnity
      @CodingWithUnity  4 года назад +2

      maybe this will help :)
      I almost don't want to make a video on it because this explains it so well and id just be copying this pretty much hahaha
      www.reddit.com/r/Unity3D/comments/fqabkx/i_tried_to_explain_procedural_animation_in_10/

  • @mrjosh218
    @mrjosh218 2 года назад

    Hi do you have a tutorial like this but for spine animations in unity?

  • @GymCritical
    @GymCritical 4 года назад +5

    Know what’s crazy, I accidentally made an override controller yesterday, and then promptly deleted it because “if you don’t know what it does, don’t touch it”. Then you showed up.

    • @CodingWithUnity
      @CodingWithUnity  4 года назад

      haha thats awesome :D

    • @pouks
      @pouks 3 года назад

      you can check up what it does on the unity documentation tho

  • @BastionKadabr
    @BastionKadabr 3 года назад

    Hello, how to connect GetCurrentAnimatorStateInfo and GetCurrentAnimatorClipInfo to get a state from clip and a clip from state ? thanksis
    it a good idea to call string name State & Clip the same ?

  • @rushikore
    @rushikore 3 года назад +1

    For the following code
    [SerializeField] private AnimatorOverrider[] overrider;
    Im getting :The type or namespace name 'AnimatorOverrider' could not be found (are you missing a using directive or an assembly reference?)
    this error

    • @CodingWithUnity
      @CodingWithUnity  3 года назад

      hover over the line and see if you get an auto fix for adding the using statement

  • @cahydra
    @cahydra 2 года назад

    Lord and savior coding with unity

  • @firdiansyahramadhan7541
    @firdiansyahramadhan7541 2 года назад

    did anyone know how to make it interpolated? , when changing between controller?

  • @gxguy2906
    @gxguy2906 Год назад

    If anyone could not get the AnimatorOverrideController to show in the editor like in the video, you must create the Animator Override Controller first before the scripting part.

  • @Sidtfrith
    @Sidtfrith 2 года назад

    does this program possible for if I want to change attack speed animation for my character?

    • @CodingWithUnity
      @CodingWithUnity  2 года назад +1

      There's a parameter you can change if you just want to change your attack speed.
      If you wanted to use this and change your speed, yes will work

  • @milodawg293
    @milodawg293 3 года назад

    Hey, love the video, and maybe you can help me out, maybe I'm just dumb or something, but do you have to download an extra package to get the "AnimatorOverrider"? As of now, I just swap out the runtimeanimatorcontroller and all parameters get reset back to their default value, but when I try to do the same line of code, "[SerializeField] private AnimatorOverrider", it just comes up as an error and says it doesn't exist ;-; As of now, I'm using Unity 2019.3.11f, so maybe that's why?

    • @CodingWithUnity
      @CodingWithUnity  3 года назад

      public AnimatorOverrideController overrideController;
      try that

    • @milodawg293
      @milodawg293 3 года назад

      @@CodingWithUnity That's what I do and the parameters still get reset T_T This is the line of code that changes my character's animations:
      //Puts the character's animations in place so the character won't look like they are running without a weapon
      anim.runtimeAnimatorController = wep.weapon_CharacterAnimations;
      the "anim" is the animator component of the character. The new AnimatorOverrideController that I'm trying to give my character is on the weapon, so I basically just drag and drop lol. If this is the correct code, but there is something after or before I can put that would have my parameters not reset, that would be amazing. I have already tried saving certain parameters in the code and re-inputting them onto the new animator overrider, but it just makes my character go to the entry state, then quickly transition to whatever was saved.

  • @ardagon385
    @ardagon385 4 года назад

    is it bad that my statemachine currently looks worse than 00:09 =)

  • @themaskyyt
    @themaskyyt 3 года назад

    AnimatorOverrider doesn't even exists in the API docs, which is really weird. Probably something on a preview package?

    • @CodingWithUnity
      @CodingWithUnity  3 года назад

      docs.unity3d.com/Manual/AnimatorOverrideController.html

  • @jorgearturoalvarezcenal6292
    @jorgearturoalvarezcenal6292 3 года назад

    Hi ! nice tutorial, but i dont have the AnimatorOverride class!! What have i do to get that? thanks for all!

    • @CodingWithUnity
      @CodingWithUnity  3 года назад +1

      That's odd!
      It should be a built-in feature. I suppose its possible its in a separate package in package manager but I dont think it is

    • @jorgearturoalvarezcenal6292
      @jorgearturoalvarezcenal6292 3 года назад

      @@CodingWithUnity thanks!! i will investigate it !!

  • @kitmen5649
    @kitmen5649 3 года назад

    I can't understand why I don't have an Override animator class(

  • @Dippps
    @Dippps 4 года назад

    I didnt understand most but maybe later i will.

  • @Liqvidniy
    @Liqvidniy 4 года назад

    Animation override controller could also be used to override states at runtime. An individual state or the multiple states at once (you can create a new animation controller override and proceduraly select different animations and override different states).
    docs.unity3d.com/ScriptReference/AnimatorOverrideController.html

    • @Liqvidniy
      @Liqvidniy 4 года назад

      Video does not show that runtime overriding is even possible(or maybe I have not listened carefully :)). I initially fought that it was only possible through a predesigned controller overrides created in the editor(because not everything you create in the editor can be created at runtime). But in fact, you can also create a controller override at runtime and mix and match animations. This is a very good news, at least for me.

  • @erikm9768
    @erikm9768 3 года назад

    not really useful tho, since now you need an override controller for each animation instead, almost more work than just adding animations in the animator in the first place. what we want to know is how to override the animator with the name of the animation in code directly.

  • @rbanister100
    @rbanister100 3 года назад

    02:42 Why do you always say
    "Buh-ins",
    instead of
    "But-tons"???
    No need to reply. This is a rhetorical statement...

    • @CodingWithUnity
      @CodingWithUnity  3 года назад

      haha, that's funny.
      Its probably my souther accent :) I'm from Georgia