2D Animation in Unity (Tutorial)

Поделиться
HTML-код
  • Опубликовано: 28 ноя 2024

Комментарии • 3 тыс.

  • @ElS3rna
    @ElS3rna 4 года назад +1446

    oh boy, if it took brackeys 20 minutes, im gonna be here till tomorrow

  • @IanAnimatesBagels
    @IanAnimatesBagels 4 года назад +547

    GUYS! If you're jump animation isn't working:
    (starting for a split second before you leave the ground)
    you don't need to add any ridiculous code. you don't need to modify the character controller. All you need to do is go to both of the exit transitions from the jump animation and turn ON the "Has Exit Time" parameter.

    • @IanAnimatesBagels
      @IanAnimatesBagels 4 года назад +25

      (and also make sure your ground check is outside of your bottom collider)

    • @omegachonker9987
      @omegachonker9987 4 года назад +16

      thanks this really saved me from insanity xd

    • @omegachonker9987
      @omegachonker9987 4 года назад +9

      however you do have to set the jump animation to exactly the time you spend jumping otherwise you either end the animation in mid air and it looks really weird if you make it to short and if you make it too long then you end up on the floor looking like your falling
      anyone got a workaround?

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

      @@harshitpal4996 do you have it set to play in the animator controller and have the animation triggered by script like in the video?

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

      Thanks!! you saved me :)

  • @Ball_Zach
    @Ball_Zach 3 года назад +485

    If you need to press space 2 times to play the animation,
    You need to go in the CharacterController2D script and change on the line 130 the false to true.
    Hope this Helped!

  • @CarboAter
    @CarboAter Год назад +31

    My man left RUclips years ago, still the best tutor out there. Thanks for all you have done Brackeys:)

  • @xavierturcotte7777
    @xavierturcotte7777 3 года назад +47

    For those who had an error where Idle and Crouch animation are playing at the same time, when you click the player, at the top of the inspector you should see where it is written "Layer". By default the Layer is set to Default, so what you should do is add a new Layer called "player", set the player's layer to that new layer, and finally uncheck the layer at the "what is ground" in the character controller.

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

      Thanks a lot, you rescued me

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

      Thank you for the tip, but mine still seems to be trying to activate both without pressing anything...

    • @onionhead8399
      @onionhead8399 2 года назад +2

      i don't know if you still alive but you saved me after hour of suffering

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

      when i click on "what is ground" they dont show me uncheck option how i uncheck player layer?

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

      what a champ

  • @ZickyNee
    @ZickyNee 3 года назад +192

    once again brackeys has the simplest and most effective solution - we miss you boss!

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

      hey man youre like the most recent comment on here and im having trouble with the events component under the character controller script, i cant find a solution to it and a i was wondering if you knew

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

      Yea true

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

      most effective - kill me

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

      @@jood7449 if i were you id join the discord if you haven’t. Theres a bunch of smart ppl that will help.

    • @Euler123-h8n
      @Euler123-h8n 3 года назад +2

      its a nice tutorial, but using physics for 2d collisions is not efficient, physics is very expensive...you should use tiled based collisions instead...

  • @SantoshP1354
    @SantoshP1354 2 года назад +32

    For those struggling with jumping animation playing for only one frame:
    1. Go to somewhere around Line 127
    2. Change "m_Grounded = false" to "m_Grounded = true"
    If you're having trouble finding this line, it should be after the following if statement:
    "if (m_Grounded && Jump)"

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

      Bro, TYSM you saved my life

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

      Thank you so much!

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

      Thanks mate, this is what i was looking for

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

      THANK YOU. U R A LEGEND 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

    • @ziadhassan7
      @ziadhassan7 Год назад +3

      And you also need to check off (can transition to self ) on the transition from anyState

  • @OGMoltac
    @OGMoltac 3 года назад +113

    I would be lost without Brackeys, thank you for everything you have done

    • @Officergizmo
      @Officergizmo 3 года назад +3

      If you would only have known

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

      @@Officergizmo lol

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

      Please tell me how you add character controler

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

      @@magiclessbrat8501 its complicated

  • @bguilleminot
    @bguilleminot 4 года назад +30

    If anyone is having trouble with the jump animation, check that your ground's layer is set to "ground". Mine was in "default" layer and as soon I changed it to ground everything started working.
    Do what Dante says too: "find the ground radius variable [in character controller 2d script] and change it to a lower number like .05"
    Hope this helps

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

      If the jumping animation doesn't work still, maybe try keeping on exit time for when it switches to idle or running. Don't keep Transition time. Only keep it for when it goes from Any State->Jumping. Turn off exit time too on Any State->Jumping. I hope it helps because it worked for me. Not the perfect solution, but it works. I know I'm coping and pasting on everything
      EDIT: don't do it it causes a weird glitch if you keep pressing the jump button in midair.

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

      my character more like a meatball (the free unity asset with that red ball like character) and the slopes was not triggering the grounded bool in character controller. Normal terrain was fine even without any layering. Adding layer didn't worked so I went ahead and edit the character controller to add a second ground check and placed it both to each edges of the character and it worked wonderfully.

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

      I couldn't figure out the first one, but the ground radius variable worked!

  • @licensetothrill
    @licensetothrill 5 лет назад +7

    In case he doesn't mention it in the video, there's a reason that sprite sheets and atlases were developed and are still used in games today. They greatly save on memory and runtime because only a single instance of the sprite array image is loaded into memory at once, and all draws simply render a specific sub-section of the same file pointer in memory.
    In Unity, you can see this in action with the batching stats. This is an important concept in any engine, however. Including ones like Unreal or Love2D or Godot or Lumberyard. It's an important concept regardless of the engine, language or technology.

  • @jarvis911
    @jarvis911 6 лет назад +18

    I just started getting into C# and game making in Unity again after hitting a brick wall and quitting a couple of years ago but your videos are really helping me grasp C# and Unity much more than I did before, thanks man I appreciate it!

  • @somieuler-ajayi5246
    @somieuler-ajayi5246 2 года назад +323

    Problem:
    If you can't find the sample rate select the three buttons in the top right corner of the animation tab and select show sample rate

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

    Thy master shall be remembered
    thanks for the experience brackeys
    4 months of you gone is like a decade to me

  • @danybeam
    @danybeam 5 лет назад +9

    IDK if anyone will see this comment
    But if your OnLanding is being called too soon and you don't want to change your jump force for whatever reason, try moving your ground check a little more to the center and actually a little higher than you would expect to be the "right" Y position.
    I set mine a little higher than what seemed correct (was right on the feet moved somewhere at shin level) and it worked perfectly

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

    The best fucking tutorials on the fucking internet. You deserve a reward man. Fucking hell man I do not know where I would be without this channel.

  • @vasil-yt
    @vasil-yt 6 лет назад +498

    Skeletal animation would be so helpful and it looks quicker too

    • @NotBanned_
      @NotBanned_ 6 лет назад +51

      It is less quality, of course.

    • @crob3545
      @crob3545 6 лет назад +5

      Not Enough Horror. It seems it would be good for a 2D physics based fighting game like the one Im gunna try make

    • @Issung123
      @Issung123 6 лет назад +27

      Both have their pros and cons, you cannot get a pixel style like in this video with skeletal animation

    • @Mrabet_Houssem
      @Mrabet_Houssem 6 лет назад +5

      actually you can , look for Dead Cells

    • @cocobos
      @cocobos 6 лет назад +6

      sprite swap is the best for pixelarts though.

  • @ralphcalzada4767
    @ralphcalzada4767 2 года назад +5

    i miss this channel

  • @adriking5383
    @adriking5383 4 года назад +275

    Animations Sample doesnt exist for me :/
    Edit: I found If you click on the 3 dots on the right of the animation tab you can select "Show Sample rate"

    • @Tortuex_
      @Tortuex_ 4 года назад +3

      thank you so much couldn't figure it out

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

      @@Tortuex_ How did you do it ? I can't seem to find it, the three dots only propose to close tab or add another for me

    • @Tortuex_
      @Tortuex_ 4 года назад +15

      @@florentbacale3280 it's the three dots right under those, it needs to be on the animation panel and not the "global" panel :) try and find three dots below the ones you found ;)

    • @stunity1767
      @stunity1767 4 года назад +4

      Thank you so much, this really helped!

    • @anishsrivatsan2332
      @anishsrivatsan2332 4 года назад +3

      Thanks a lot! I couldnt find it either, but your comment helped :)

  • @zaichothepsychoofficial7208
    @zaichothepsychoofficial7208 3 года назад +3

    FOR JUMPING, If you have an animation that is more than one frame long and animation is stuck on first frame do this
    Click on the transition from ANY STATE to JUMPING --->Untick 'Can Transition To'.
    this was causing an infinite loop allowing the animation to loop into restarting, staying in the first frame

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

      Thank you so much

  • @suryamdg
    @suryamdg 3 года назад +5

    For those of you who only see the Jump Animation for a split second this simple solution might work:
    *Solution:* Decrease the ground check radius and check if it works properly (if it still doesn't work decrease it even more). This also might not work if you have kept the game object that checks if touching ground too much below the player.
    *Explanation:* The reason why this is not working is that the program is checking for ground at that very split second of the jump since the program is updating too fast the animation check option keeps returning to false. If you decrease the radius of the ground check then by the time the program checks for ground the overlapping circle would have moved away from the ground due to low radius thus not overlapping anymore.
    *Don't add Exit time I know it works but the problem with that is it only works for fully flat ground, suppose you are jumping to a level higher than you then the sprite would be touching ground before the exit time is over thus remaining in jump animation for more time in spite of touching ground*

  • @th3-wolf130
    @th3-wolf130 5 лет назад +4

    I love these tutorials, they are the only reason i know how to do remotely anything in UNITY

  • @Spartaton
    @Spartaton 6 лет назад +58

    I think covering skeletal animation is a great idea. Perhaps consider looking at the new skeletal 2D animation being integrated into Unity rather than or in addition to Anima 2D.

    • @jonatan01i
      @jonatan01i 5 лет назад

      @Bobby5z0 you bastard xd

  • @alextashkov2772
    @alextashkov2772 5 лет назад +6

    Ok i know im late but for those of you reading this and having the bug with the jumping animation failing to transition to the idle or running animation - i think i found a fix
    (atleast it fixed mine)
    SO
    1 - find the line if(!wasGrounded) in the script that they provided and change it to if(!wasGrounded && m_Rigidbody2D.velocity.y

  • @abdoudjam6846
    @abdoudjam6846 6 лет назад +1301

    Thanks a Lot ! yes Please skeletal animation would be so helpful ! ( Like if you agree ) !

  • @eziothegoat
    @eziothegoat 6 лет назад +266

    Please do game saving/loading tutorial!!

    • @AhmedKhalfYolo
      @AhmedKhalfYolo 6 лет назад +5

      Just use player prefs

    • @AhmedKhalfYolo
      @AhmedKhalfYolo 6 лет назад +4

      He made a video about saving and loading high score

    • @eziothegoat
      @eziothegoat 6 лет назад +6

      I mean about saving and loading if you exit the game and you want to continue playing later ..

    • @AhmedKhalfYolo
      @AhmedKhalfYolo 6 лет назад +2

      Yea same technique

    • @ererbe
      @ererbe 6 лет назад +1

      or you can use save game free (it is very helpful in my eyes)

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

    If the jumping animation doesn't work still, maybe try keeping on exit time for when it switches to idle or running. Don't keep Transition time. Only keep it for when it goes from Any State->Jumping. Turn off exit time too on Any State->Jumping. I hope it helps because it worked for me. Not the perfect solution, but it works.
    EDIT: don't do it it causes a weird glitch if you keep pressing the jump button in midair.

  • @r3ady150
    @r3ady150 4 года назад +8

    For those who are not seeing the samples option. Maximize the animation window and you should see 2 pairs of 3 dots in top right corner. Select the bottom most one and select show samples. I spent about an hour finding out how to do that one thing. SMH @ unity

    • @claidei0011
      @claidei0011 2 года назад +2

      Thanks! I almost quit after I couldn't find it

    • @henrytai4030
      @henrytai4030 2 года назад +2

      I love you so much

  • @deano1
    @deano1 4 года назад +123

    The problem - everything.
    The soloution -
    cry

    • @thananjaijongrak7604
      @thananjaijongrak7604 4 года назад +7

      20 mins for Brackeys to do jumping animation.
      It took me 2 whole hours to solve all the problems.
      bool meCrying = true;

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

      And i have no idea how to play cutscenes.
      Cry==1
      If Cry == 1:
      Print("big sad')

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

      @@kacpercicharski4193 brackets also has a vid on that

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

      Brackeys**

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

      @@kacpercicharski4193 also the syntax in that is preeeetty wrong 😬

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

    In my game the "Crouch" animation made me hover, so I edited the Character Controller a lil so it removes 2 colliders. Now it's Smooooth.
    Loved the vid, long time coder, first time unity user.
    Definitely a thumbs up!

  • @imconfused6955
    @imconfused6955 6 лет назад +169

    Your On Land event is checking too soon and that's causing my character to stop jumping immediately after leaving the ground. Any idea on why this is happening and how I can fix it?

    • @alizlatan4331
      @alizlatan4331 6 лет назад +6

      I'm Confused same

    • @teda-t6757
      @teda-t6757 6 лет назад +6

      Same here.. :/

    • @teda-t6757
      @teda-t6757 6 лет назад +17

      I have found a solution that works for me - it may be the same reason for you. I needed to increase the Jump Force and it worked fine. I think it's because when the force is too low, the play doesn't leave the ground quick enough before the On Land event is called to ground it.

    • @alizlatan4331
      @alizlatan4331 6 лет назад +6

      Ted Alden-Templeman it didnt work
      (And do you know why the idle animation & crouching animation play both at the same time)?

    • @d3athstalker
      @d3athstalker 6 лет назад +117

      Did you find an answer to this? The problem roots from the Character Controller 2D script but as of now I can't find a way to stop it from checking so fast
      EDIT: I actually just implemented something to delay this check from happening so quickly. This is the first thing that came to mind so it might not be the best option but you can download my edited script here : drive.google.com/file/d/1AMkNgVx0mRJHY9Jsiv_r5ifnYBuo7D94/view?usp=sharing
      I added a delay time variable which can be modified in the Unity Inspector under the Character Controller 2D script.
      If you use this script instead of the one supplied in the GIT repo it should work for you as well.

  • @leopoldo1586
    @leopoldo1586 6 лет назад +52

    I would LOVE a video on anima 2d

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

    Incredibly easy and clear! Definitely you are the best tutorial channel about Unity!

  • @pastaloverohyeah
    @pastaloverohyeah 2 года назад +5

    If your jump animation keeps looping, go to your jump->idle transition and change the parameter to "Speed Less Than .01" :)

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

      Didn't work 😭

  • @MCcoffa
    @MCcoffa 4 года назад +14

    you.are.the.best... literally saving my school semester XD

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

    All of your Unity tutorials are absolutely amazing, they've been helping me so much in learning game development! Keep up the great work!

  • @gmbalacera6086
    @gmbalacera6086 5 лет назад +9

    i love it, just recently bought the aseprite and im willing to make my own videogame, these videos are a lot of help! ♥

  • @henryjohn6244
    @henryjohn6244 5 лет назад +6

    finally, after the error are occurrence. I can make animation for my character. Thank you so much Brackey.

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

    The great thing is that you keep your *smile* _visible>true_ in all your videos...keep going!

  • @chrismeier3923
    @chrismeier3923 5 лет назад +20

    I am finding that all of my character movements and animations work perfectly, but the jump animation doesn't activate unless my character is already off the ground. I tried moving my ground check up a bit, but it just looks like the jump animation flickers and then stops. While I am in the air, if I hit the jump button again, the animation works. Any suggestions?

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

      @animeharmonics Thank You!!!

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

      Yo same

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

      @animeharmonics It didn't work for me

  • @paulbergdev
    @paulbergdev 4 года назад +3

    For those who have problems with the CROUCHING ANIMATION FLICKERING WITH IDLE
    Make sur to have all of your layers right and all, but in my case it didn't work even though everything was good.
    I had to reorganize the whole crouching node in the animator. I made one transition from "Any State" to crouching with the only condition that isCrouching is set to true, and then the transitions to run and Idle juste like he did.
    Aside from that very good tutorial!

  • @Broockle
    @Broockle Год назад +2

    Gotta make sure the animator is on the same object as the sprite renderer.
    And you can reveal samples by clicking the triple dot on the right of the animation window and hit "show sample rate"

    • @Stanley_S
      @Stanley_S 10 месяцев назад +1

      thank you so much

  • @Natasha-rm5zi
    @Natasha-rm5zi 5 лет назад +5

    For jumping animation problem, open character controller script and find these lines at the end of the Move void:
    if (m_Grounded && jump)
    {
    // Add a vertical force to the player.
    m_Grounded = false;
    m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));
    and then just delete m_Grounded = false;
    WIN!

  • @benevolent9130
    @benevolent9130 3 года назад +25

    For everyone that's struggling with an error where Idle and Crouch animation are playing at the same time to the Character Controller SCRIPT line 67 or 69 there is a ! before crouch. I struggled hours

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

      omfg thank you!

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

      Oh my gosh this literally saved my sanity!!! Thanks for the tip

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

      woahh thank you!

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

      I had the same problem and I tried to erase the ! at line 67 , but that made the player uncrouch when stop pressing the crouch button even if there is a ceiling. What I did to solve the problem was to add a new Layer(not sorting layer) called player, put the player in that layer and finally disabling the player layer in the "what is ground" in the character controller.

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

      thanks a lot you are a saviour!

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

    the only tutorial that actuallly helped me even 2021

  • @zonevaldez9716
    @zonevaldez9716 5 лет назад +76

    please help me! Why i need to double press the UP/W key to see the animation of jumping?

    • @sheadex4786
      @sheadex4786 5 лет назад +6

      Same for me :(

    • @Kardiiacc
      @Kardiiacc 5 лет назад +5

      me to

    • @ethanevans2402
      @ethanevans2402 5 лет назад +20

      I think it has something to do with his character controller script. If you look at the FixedUpdate function in his character controller he invokes the on land event whenever the character’s ground check intersects the ground and when the character was falling before that.
      The problem is that when your character jumps there is a split second where after you’ve jumped, the character’s ground check is still touching the ground, which means the character controller thinks you were just falling and just landed.
      This is why you can see the animation for a split second before it goes back to idle. Once you’re up in the air and press it again the animation plays because the ground check is far enough away from the ground to not trigger the event.
      Working on a solution right now.

    • @provensi
      @provensi 5 лет назад +8

      here guys
      private void OnCollisionEnter2D(Collision2D collision)
      {
      if (collision.collider.gameObject.layer == 9)
      {
      OnLandEvent.Invoke();
      }
      }
      delete where the another OnLandEvent.Invoke() is (FixedUpdate() i think), in my case the ground layer is 9, so change it if not yours

    • @danielselaru7247
      @danielselaru7247 5 лет назад +3

      Well, I did this and it's kind of working :))
      if (Input.GetButtonDown("Jump"))
      {
      jump = true;
      animator.SetBool("IsJumping", true);
      }else if (Input.GetButtonUp("Jump"))
      {
      jump = true;
      }

  • @INAVACL
    @INAVACL 4 года назад +3

    This is exactly the video I needed! I made different art pieces for animating in unity and wasn't sure how to go about it.

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

    For anyone who can't move after adding animator.SetFloat, make sure to click the player sprite and then drag the animator component into the "Animator" section of the Player Controller component!

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

      Bro I was starting to panic when I couldn't figure out how to fix it. Thanks to you and all of the other helpful commenters I have been able to understand these small differences that drastically affect the game. Yee Yee.

  • @isaacwilkerson4057
    @isaacwilkerson4057 4 года назад +18

    im using my own script and was wondering if anyone knows how to add the events to my character controller

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

    Thank you so much I actually made a dumb mistake of not finishing the video so I missed all the script parts and had a lot of trouble with it like for a day and then I went back and saw that we had to script and I was literally mindblown bruh. IT WAS SO BAD 😭😭😭 But luckily I finished the video this time and got my animations!!!! TYSM!!!!!

  • @arcy9289
    @arcy9289 3 месяца назад +1

    Adding all the animation took longer than making a menu and exporting the game xD Thanks though this is invaluable info in a very digestible format!!

  • @小夢-k9o
    @小夢-k9o 2 года назад +5

    Hey guys I found something It might be work on jump animation
    Just take your 'ground check point' up a little higher then ground collider
    cause if too deep it will check for twice (sry for my bad english:(

  • @evancarson5301
    @evancarson5301 6 лет назад +18

    I need learn more coding and this is a great vid

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

    one of my favourite videos!

  • @PoppyTheDrapica
    @PoppyTheDrapica 5 лет назад +17

    I'm crying my character is walking and moving and ahsjdkgashjfgfj THANK YOU

  • @MaximumSpice
    @MaximumSpice 4 года назад +9

    Great tutorial but I'm not sure why you'd skip the creation of the events. I get the point is to simply do the animations but I'm following the guide in my own character controller I made myself and now I'll have to research how to add events in. Not hard, but why skip over it, extra bonus content we could learn.

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

      Help please: what should i put inside the inspector for the player, about What is Ground, about Ground check, about Ceiling Check and Crouch Disable Collider????

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

      @@LeHalazoone did you follow the tutorial? If your not sure how to use the inspector with variables from a script yet sounds like you need to slow down and do more basic tutorials first.

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

      I have a problem with my scripts that are not reconized, i can not join it to the inspector

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

      @@LeHalazoone you don't join them to the inspector you put a script on a gameobject like the player object or simply a cube or even an empty gameobject then you can 'inspect' the script over on the inspector window. You should watch the unity tutorial roll the ball first. this is way to advanced for you atm. slow down and enjoy the learning phase of game dev, dont rush through it.

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

      @@MaximumSpice Thanks very much.
      I meant i drag and drop the script in the bottom of the object in the inspector. It is the same manipulation i think. I tried it many times and it works.
      But i do not understand why it does not in my case ?

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

    I miss you, Brackeys

  • @robertharbison4199
    @robertharbison4199 6 лет назад +4

    Your tutorials are so helpful. I would love to see a skeletal animation one! Thanks for your hard work.

  • @ahorseisahorseofcourse
    @ahorseisahorseofcourse 6 лет назад +5

    Thank you so much, this is saving me during my platform design final.

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

    SUPER AWESOME!!! I don't know why everyone is complaining. Everything in this video works fine and I'm making this game in 10/20 using the spaceman animation. All codes and everything else works fine. Honestly you just have to be patient and be able to problem solve. I feel people give up on themselves very easy. Trust me...I spent over 7 hours alone trying to get his crouch animation to work. i erased and rewrote the code...I went back and rewatched the video plenty of times...I am happy to say that yesterday i figured out the problems and I couldn't be more happier. It was a super easy fix which honestly pissed me off. As soon as i got it to all work. I saved the game and closed it. Thanks for everything and I plan to watch most of your vids.

  • @devmelonroblox
    @devmelonroblox 4 года назад +4

    my jump animation plays for like 0.0001 seconds because it touches the ground when i jump how do i fix this?

  • @thekiwisedge3498
    @thekiwisedge3498 5 лет назад +28

    When I have the Character Controller 2D script open the events show, and I can’t access them. What should I do?

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

      in this Prohect New Script

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

      You want to press the plus sign and then drag your player movement script inside of your event.

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

      how do i add events?

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

      i am having the same issue now

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

      but i cant see any events at all under the script

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

    We miss you Brackey😔😔😔😔

  • @aprimic
    @aprimic 6 лет назад +97

    You never explained events in the character controller script

    • @Jason_fox
      @Jason_fox 4 года назад +12

      Right? He just said he added some code like its not important but its missing for me.

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

      @@Jason_fox buckaroo he added it to the character controller script. He wasnt talking about the current script

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

      @@jerzyfice1426 I was using the script that came with all the other files. And the updated script that actually had events had to be downloaded directly

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

      @@Jason_fox ty dude i tought i had the most recent script (thumbs up)

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

      @@jerzyfice1426 Wait, what? Where can I find the new script?

  • @watagree
    @watagree 6 лет назад +7

    Hey i really like your content. I don’t know anything about coding and stuff. And I don’t watch your videos to learn but simply because I enjoy them. Game development is so intriguing and it looks really cool. I hope I get a change to actually learn from your videos when I finally get the time. ALSO ARE YOU GUYS FULL TIME RUclipsRS OR ARE YOU AN INDIE STUDIO. I ask this because I would really like to see a fully fleshed out game of yours!!!!!!!

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

    If u are not getting "sample" in ur animation window just click on the three dots in the top right corner of the "animation window" and not inspector window , then click on show sample rate
    Thats All

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

      Thank's !

  • @jennajaillet6942
    @jennajaillet6942 5 лет назад +14

    So I noticed when my character jumps all is well, however when my character just walks off a ledge, the idle animation continues to play. Any thoughts on how to implement a fall into the code. (Sorry, I'm new at this but very excited to learn!)

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

      You could create a new animation strictly for falling then create a bool that turns on when falling and not jumping and then set the idle animation to transition to the fall animation when the bool is set to true

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

      @@ashtimbog whpa 8 hours ago

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

      @@someobscuremusicchannel lol 3 hours ago

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

      @@Liquid23 ee 14 minutes ago

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

      @@someobscuremusicchannel hddeuebhe 2 minutes ago

  • @Xeratas
    @Xeratas 6 лет назад +25

    so there is a bug, when you jump and land and for some reason your movementspeed is exactly 0.1 he will stuck in the jump animation.

    • @middlemarv
      @middlemarv 5 лет назад

      Thank you so much. You sent me down the right road. I was having this exact problem but I had it set to greater than 0.01. Set it to Lesser no longer a problem. Cheers.

    • @pantheon4141
      @pantheon4141 5 лет назад

      Thanks a lot! you saved me a lot of trouble! \(*o*)/

    • @yuratwitch1093
      @yuratwitch1093 5 лет назад +1

      @@middlemarv Can u tell me how to do this?

    • @middlemarv
      @middlemarv 5 лет назад

      @@yuratwitch1093 I can and will. Give me 20 mins.

    • @middlemarv
      @middlemarv 5 лет назад +2

      @@yuratwitch1093 So I am going over this again as well. I lost my last build and I don't think this works as well with the newer version because I'm having difficulty with my player jumping without animation let alone with the animation. Basically though go to 5:10 he talks about how you can create two animations for the jump up and down. I think that may fix the problem however how you do that I'm not sure yet. Continuing with how Brackey is doing it. Go to 6:15 where he explains the animator than jump to 7:48 where he goes over parameters then to 1216 where he explains how to set up the transition of going to jump anytime. The time stamp 13:38 and I believe this is what I was talking about a month ago when it transitions back to the idle animation make sure jumping equals false and that the speed is less than 0.01. I hope this helps. Just curious to what version you are using. If you don't mind.

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

    omg!! thanks Bucky the ".anim" extension was missing in my case, thanks!!

  • @Gus-vz9kp
    @Gus-vz9kp 5 лет назад +24

    Hi.
    I had a problem with my character not playing the jump animation when I was pressing the jump key
    I tried to fix it for a long time but I finally found a solution
    SOLUTION!
    All you have to do is just to lift your ground check a little more up.
    Now the jump animation is working just fine
    Hope this helps!

    • @mug9785
      @mug9785 5 лет назад +1

      Omg thank you savior from the heavens

    • @korytoombs886
      @korytoombs886 5 лет назад

      I just suddenly out of nowhere had this issue, I thought it was caused by an unrelated script or something. Don't know why it never caused me problems until recently, but this fixed it for sure.

    • @Sergeantpaprika
      @Sergeantpaprika 5 лет назад

      it still doesn't seem to work ._.

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

      move the ground check under the character

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

      yeeeee

  • @mauriciocortespersonal
    @mauriciocortespersonal 4 года назад +30

    is there a way to reuse the same animations (walk, jump, etc) with other sprites automatically? (to change player skins without creating all the animations again)
    i found a way but it must be a better way....
    My way is hard to explain but is like this:
    - create an empty gameobject ("Player"?) with all the individual sprites in the same position x,y,z
    - use generic names for the sprites (frame1, frame2, frame3 or idle01, idle02, jump01)
    - in the animation you want to create (let's say: "Jump") you record and set the parameter Gameobject.isActive to false on all the sprites except the one you need to that keyframe (and repeat)
    - Done.
    If you want to create a different "Skin", just duplicate the previous gameobject ("Player")
    and change the sprites (using the inspector) without changing the names of the gameobjects containing the sprites.
    - All the animations and animator-controllers can be used with this new skin automatically!
    if you have 30 animations, you wont need to create 30 more for every skin, just duplicate the first skin and replace the sprites and you're ready!
    Note: i found there's another way (ruclips.net/video/HM17mAmLd7k/видео.html), replacing the 2D texture in the lateUpdate, the tutorial is from 2014 i haven't test it yet

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

      the way you told is pretty impressive, and considering a player wouldnt have more than 30 images, 30 gameobjects also does not put load on the cpu, and also, no gameobjects are created or destroyed, just enabled and disabled... Yeah so ur solution is pretty cool

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

      Cant think of a better way

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

      I just install Unity and learn C# for like 2 months. So I wonder will my guess be usable?
      instead of duplicating 30 animators, can we apply with code?
      like create a pool of library and call the sprite that we actually need for player.

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

      Use an animator override controller my dude. I use it to copy animation transitions without all the extra work because I can just drag and drop the animations and sprites I wanna use in and PRESTO!

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

    We miss you legend

  • @Demigodish4o3
    @Demigodish4o3 6 лет назад +23

    For some reason the idle transitions to crouching animation without me pressing anything.
    The "isCrouching" Parameter keeps going On and Off automatically :(

    • @BerlandMedia
      @BerlandMedia 6 лет назад +1

      I have the same problem.. Did you find a fix for it?

    • @oooriuken
      @oooriuken 6 лет назад +10

      Check if your player has the "Player" layer assigned

    • @BerlandMedia
      @BerlandMedia 6 лет назад +1

      Worked for me! Thank you :D

    • @oooriuken
      @oooriuken 6 лет назад +9

      Also the attribute “What Is Ground” of “Character Controller 2D” need to have everything selected except for that “Player” layer

    • @harperhejter7766
      @harperhejter7766 6 лет назад

      I have the same issue. Player is on a player layer , tilemap is on a default layer and "what is ground" have everything selected except for Player layer

  • @wally4879
    @wally4879 2 года назад +2

    Tip: My issue was that the jump would display the frame for 1/10 seconds. These tips got me to the point that you had to double click W. Go through the character controller, and change !WasGrounded to WasGrounded, and !crouch to crouch. Another thing. 'Any State' has issues that I am not smart enough to understand. You have to set the transition for your malfunctioning jump animation from 'Any State' to your idle, player run, and crouch. It sucks. Here's a copy/paste from a user named Merkys on Unity questions for an example:
    "OK, because i found an answer myself, I'll write it not as comment, so it will be easier to see. For animations to work properly (except which are made by blending tree), transitions mustn't be from "Any state", because that means the state itself. For example if using "Any state" --> "Running" and transition goes with condition that speed is greater then 0.01, when your object tries to move in any direction it plays only first frames of animation, because that animation won't have time to play properly. And that happens because when condition is true animator through transition tells it to play, but transition comes from "Any state", it means from the same animation you try to play, and it goes in cycle never finishing animation."
    Unfortunately I can't post the link.
    Now, if you don't do this and go straight to setting the k_GroundedRadius to a really small number, your character will be permanently jumping, which perfectly explains what was stated above. An alternative can be checking 'Can Transition To Self' on the transition between Any State and Player_Jump. However, if you were having my issue you still need to set the GroundedRadius to a lower, sometimes absurdly lower, number.
    Hope this helps!

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

      Never mind all of this is wrong

  • @jannisben5870
    @jannisben5870 6 лет назад +19

    If your Jump animation is only showing up for a few milliseconds you have to put your Ground check a little Upwords.
    (This is the Problem I have had xD)

  • @scrub4749
    @scrub4749 5 лет назад +10

    Hey, im having a problem where while jumping my animation switches from jumping to idle animation mid jump. I would set up some kind of velocity parameter but i dont know how

    • @theemeraldfalcon9184
      @theemeraldfalcon9184 5 лет назад

      it needs to loop i've checked mine but the animation doesn't loop do you know why?

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

    I appreciate you for keeping your channels on view so that we can see other good channels for this too thank you 😭

  • @akulshaurya
    @akulshaurya 4 года назад +12

    Hi, when I used the Animations, Nothing is working... Meaning the animations are looking kind of weird, only one frame is playing and nothing else
    edit:
    Now Its working but there is no jump animation... pls help again
    edit 2:
    I fixed it.. just go in the character controller script and find a ground radius variable and change the value to 0.05f

  • @TheLastApplePie
    @TheLastApplePie 5 лет назад +11

    How do you add "Events" on a Script? i didn't use his Character Controller 2D script

    • @Petesails
      @Petesails 3 года назад +7

      I'm assuming you've got this now but for anyone else struggling
      at the top put - using UnityEngine.Events;
      then an attribute that says this - [SerializeField] UnityEvent OnLandEvent;
      then where you want to trigger the event - OnLandEvent.Invoke();
      I managed to get the last 2 lines but i couldn't work out where i was going wrong for ages turns out you need to tell is to use the events thing at the top. That is really important aparently.

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

      @@Petesails thank you thank you THANK YOU

  • @Trifox_anims
    @Trifox_anims 2 месяца назад +2

    whos back to these classics in 2024

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

    I am unsure why but when I do this for my own sprites for my game when I press play in the animation window it does not change the sprites at all, does anybody know why this is happening or a way to fix this? If so that would be very helpful!

  • @joyousgaming4935
    @joyousgaming4935 3 года назад +25

    "simply click and drag that into the animation."
    ME: clicks and drags
    *doesnt do anything*
    watches more video
    cant play the animation
    is more confused
    there is nothing simple about this

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

      check this video out it might help you : ruclips.net/video/UB1eCuM2sfE/видео.html

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

      unity is stupid. the gameobject you created the animator for HAS TO BE SELECTED to drag sprites into the animator.

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

      @@muhammadmohsen8732 No its not help... its same

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

      You need to select the object that you want to animate. If you want to animate an object named "Player", click on player in the Heirarchy or scene.

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

    His voice is really intellectually skilled

  • @williamr.vazquez619
    @williamr.vazquez619 5 лет назад +24

    How did you create your On Land Event in the "Character Controller 2D" Script?

    • @terramerc733
      @terramerc733 5 лет назад +1

      Find out how yet?

    • @emil6176
      @emil6176 4 года назад +14

      To create a event you need to do "using UnityEngine.Events;" in the top of your code.
      Then what he did was to add this code a little bit under the publics and privates.
      " [Header("Events")]
      [Space]
      public UnityEvent OnLandEvent;
      [System.Serializable]
      public class BoolEvent : UnityEvent { }"

    • @mr.potatochipp9289
      @mr.potatochipp9289 4 года назад +1

      @@emil6176 that helped a lot thanks!

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

      @@emil6176 what do you do after that because for me its still not working i have no animation

    • @solitarygrounds
      @solitarygrounds 4 года назад +3

      @@emil6176 to clear it up i cant see my function OnLanding from the function drop down! it is set to public just says No Function

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

    This guy really helps.

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

    How did you make the event for landing check ??

  • @FordivenX
    @FordivenX 9 месяцев назад

    brackeys is the goat

  • @hrishikeshnag8348
    @hrishikeshnag8348 6 лет назад +5

    Brackeys why aren't you uploading videos?

  • @ceciliacecchet5869
    @ceciliacecchet5869 Год назад +4

    If the samples aren't showing up in your unity animation tab, press the three points that are on the corner of the tab (the animation tab) and press "show sample rate"

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

    Lifesaver! It takes me a lot to time to animate through code!

  • @frannypack8879
    @frannypack8879 6 лет назад +4

    Hey Brackeys, been following your tutorials so far and I'm learning a lot through it. I'm currently trying to figure out melee attacks and how to script it. I noticed you didn't have a melee combat tutorial video for 2d games, would you be willing to make one?

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

    BROOOOOOOOOOOOOOOOOOO!! JUST WHAT I NEED IT!!!!

  • @Victor-kt6qn
    @Victor-kt6qn 4 года назад +5

    Someone help!!!
    My jump animation only plays the fall animation at the peak of the jump. Before the peak it displays the idle animation also after the peak it plays the idle animation....
    Help.
    It looks like my character is having a spasm

    • @j.kkidding9764
      @j.kkidding9764 4 года назад

      oh boy.. thats really hard man. I hope you find a solution to it!

  • @yassinhakim3742
    @yassinhakim3742 4 года назад +11

    help pls my character would not do the jump animation cz the "isJumping" gets activated and deactivated in a nanosecond

  • @losheida0
    @losheida0 2 года назад +2

    To fix any weird crouching issue add the arrows that are coming from Any State, IsCrouching = false

  • @SuperMrMuster
    @SuperMrMuster 6 лет назад +4

    How do you change your sprites facing? I've been going back and forth in your video, but I can't find the part where you tell Unity to mirror the sprite if the character is moving left. For you, it just seems to work right out of the box.
    I wrote my movement script before watching this video, so I don't know if you have it somewhere in there.

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

      In the character controller, he uses a method called flip to flip the character depending on the direction its facing (it uses the horizontal input from the user, ie -1 is facing left, 1 is facing right)

  • @Ravik-no6wx
    @Ravik-no6wx 6 лет назад +4

    woah nice tut, Im just curious - r u usin' some extension to color ur code or u customize all of it in the vs?

    • @maroc7697
      @maroc7697 6 лет назад

      I code in vs and (in default) it seems like in video, maybe you have to update it :)

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

    Despite the fact that there are many game dev tutorials in skillshare, i still prefer brackeys LOL

  • @30may10
    @30may10 5 лет назад +4

    why my character just look at the direction of right? and pls i need help i used 2D Platform Controller from the asset store and is this made the way wrong?
    please i need answers

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

      Add this to your void Update() code-
      if (Input.GetAxis ("Horizontal") < 0)
      {
      Vector3 lTemp = transform.localScale;
      lTemp.x = -1;
      transform.localScale = lTemp;
      }
      if (Input.GetAxis ("Horizontal") > 0)
      {
      Vector3 lTemp = transform.localScale;
      lTemp.x = 1;
      transform.localScale = lTemp;
      }

  • @Kazuhira64
    @Kazuhira64 5 лет назад +8

    After i have done everything with the crouch animation
    if i hold down the crouch button my animation is spazzing

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

      As Shirshajit Singha said there`s an error in the character controller script in the line 67/69 change "!crouch" with "crouch"

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

      @@TheNightteror Thx dude. Did save me some hours!

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

    I dont need no skillshare I got brackeys and you cant take that away fro, jinxed it.