How to change your Animators Animation clips at runtime in Unity3D

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ต.ค. 2024
  • 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.c...

ความคิดเห็น • 71

  • @willycampos6101
    @willycampos6101 4 ปีที่แล้ว +14

    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

  • @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.

  • @bryanirvine3914
    @bryanirvine3914 3 ปีที่แล้ว +7

    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!

  • @Yenrei
    @Yenrei 3 ปีที่แล้ว +3

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

  • @LaurenceCreates
    @LaurenceCreates 4 ปีที่แล้ว +7

    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

  • @ondrejpolcar2872
    @ondrejpolcar2872 ปีที่แล้ว

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

  • @fulgencejuniorlohore854
    @fulgencejuniorlohore854 ปีที่แล้ว

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

  • @DavidZobristGames
    @DavidZobristGames 2 ปีที่แล้ว

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

  • @danielnnadi6614
    @danielnnadi6614 2 ปีที่แล้ว +1

    This totally saved my life

  • @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.

  • @matthewbennett8510
    @matthewbennett8510 2 ปีที่แล้ว

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

  • @NPCsz
    @NPCsz 3 ปีที่แล้ว

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

  • @ezydenias8505
    @ezydenias8505 2 ปีที่แล้ว

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

  • @MrMariy0
    @MrMariy0 2 ปีที่แล้ว

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

  • @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

  • @adamcourtney8255
    @adamcourtney8255 2 ปีที่แล้ว

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

  • @reendevelops
    @reendevelops 3 ปีที่แล้ว

    This will greatly help with my equipping system!

  • @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

  • @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

  • @blah2758
    @blah2758 3 ปีที่แล้ว

    amazing, this example was just what I needed thanks

  • @entertainmentoverloaded5700
    @entertainmentoverloaded5700 3 ปีที่แล้ว

    Fantastic video :)

  • @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/

  • @naftalilipman8153
    @naftalilipman8153 3 ปีที่แล้ว +2

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

  • @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.

  • @GameDevBryant
    @GameDevBryant 2 ปีที่แล้ว

    Thanks, this is really hepful!

  • @peterschreuderr
    @peterschreuderr 2 ปีที่แล้ว

    Thank you!!

  • @JongHyunSM
    @JongHyunSM 4 ปีที่แล้ว

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

  • @FaeranJourneys
    @FaeranJourneys 4 ปีที่แล้ว +2

    You Rocks! men!

  • @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.

  • @abassianis9237
    @abassianis9237 4 ปีที่แล้ว

    Great Video Thank you

  • @cahydra
    @cahydra 2 ปีที่แล้ว

    Lord and savior coding with unity

  • @FreakyStudios
    @FreakyStudios 4 ปีที่แล้ว

    Hello bro how can i disable the animator controller override !

  • @465Davide
    @465Davide 3 ปีที่แล้ว

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

  • @a.technology1446
    @a.technology1446 4 ปีที่แล้ว

    Amazing

  • @lukastomasek8038
    @lukastomasek8038 4 ปีที่แล้ว

    Great tutorial !

  • @rushikore
    @rushikore 4 ปีที่แล้ว +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  4 ปีที่แล้ว

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

  • @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

  • @mrjosh218
    @mrjosh218 2 ปีที่แล้ว

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

  • @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 ?

  • @Sidtfrith
    @Sidtfrith 3 ปีที่แล้ว

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

    • @CodingWithUnity
      @CodingWithUnity  3 ปีที่แล้ว +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 4 ปีที่แล้ว

    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  4 ปีที่แล้ว

      public AnimatorOverrideController overrideController;
      try that

    • @milodawg293
      @milodawg293 4 ปีที่แล้ว

      @@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.

  • @jorgelogan-w8v
    @jorgelogan-w8v 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

    • @jorgelogan-w8v
      @jorgelogan-w8v 3 ปีที่แล้ว

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

  • @firdiansyahramadhan7541
    @firdiansyahramadhan7541 2 ปีที่แล้ว

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

  • @ardagon385
    @ardagon385 4 ปีที่แล้ว

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

  • @kitmen5649
    @kitmen5649 4 ปีที่แล้ว

    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 4 ปีที่แล้ว

    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