Idle, Run and Jump Animations - Platformer Unity 2D

Поділитися
Вставка
  • Опубліковано 23 січ 2025

КОМЕНТАРІ • 138

  • @GameCodeLibrary
    @GameCodeLibrary  Рік тому +5

    FREE SCRIPT AND PACKAGE for all sprites, scripts, controller and player movement on my Patreon!
    www.patreon.com/GameCodeLibrary
    Save on assets at the Unity Asset Store!
    prf.hn/click/camref:1101l4cQdT

    • @odracir3300
      @odracir3300 6 місяців тому

      there's is a major headache when creating animations, and it boils my brains because no one, absolutely no one explains: that when you create the animation, you cannot click away or the editor gets ultra mega super locked.... it took me an hour to "fix", i couldn't drag pics into it, i couldn't click the dropdown for clips, i couldn't play/pause... somehow i discover (again after one wasted hour) that i needed, first that the object present in the scene (the player in this case) had the components anim_controller and animation. And second to click in the hierarchy the object to see the animation window clickable. Is it a rookie mistake ? maybe, but normally is rookie mistakes what discourage game devs.... I hope if someone goes trough this Main comment's reply, they find the answer...
      For everything else your video was really helpful in creating my animations after that issue, thanks keep it up ! 😎💪

    • @-chanlinh4485
      @-chanlinh4485 Місяць тому

      thank you muchhhhhhhhhhhhh

  • @jazioxgaming
    @jazioxgaming Рік тому +5

    Congratulations on 1,000 subscribers! It's cool to see a modern Unity tutorial!

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому

      Thank you!!! I didn’t imagine even getting 100 subs, but I’m glad so many people can enjoy and find help from my vids :-)
      I’ll keep working on cleaner and better Unity tutorials for as long as I can! I want everyone to feel like that can make whatever they want 🙏 thanks for the support!

  • @zenden1706
    @zenden1706 Рік тому +10

    SUBBED
    Thank you so much for your work!! And also your Harry Potter accent and voice makes it even better! Also, adorable sprites, and loved the Mother 3 menu arrenged theme at the end! I NEED MORE

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +4

      Hehe thank you!! You’re the first person to notice the mother 3 music 😈 it’s mother 3 for the intro song too, but the intro is pretty quiet! I’ll keep working hard for you 🫡

  • @Th3M729
    @Th3M729 Рік тому +1

    That clarity stuttering was crazy!!! Good video

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому

      Thank you :-) So satisfying to see it get fixed right!

  • @Themediocredude
    @Themediocredude 11 місяців тому +1

    My movement code was different so i had to make a new “void” where it checks if the numbers are negatives or positives and it flips them using the sprite renderer. Also your voice is so calming and great tutorial, helped me a lot.

    • @GameCodeLibrary
      @GameCodeLibrary  11 місяців тому +2

      Thank you! Glad you got it to work for you too!! 🙏

  • @hercules5546
    @hercules5546 2 місяці тому +1

    OMG THANK YOU, i was going insane, you are the first one that clearly explained the pixel per Unit, i was wondering why it looks so bad and no other tutorial explained it like you did, thank youuuu

  • @UfukDulger-iy5ez
    @UfukDulger-iy5ez 9 днів тому

    Everytime i learn different things from you. thank you.

    • @GameCodeLibrary
      @GameCodeLibrary  9 днів тому

      This makes me super happy that you’re learning things and finding the videos useful!! 🙏

  • @rafaeldpaula
    @rafaeldpaula 4 місяці тому +1

    Valeu!

    • @GameCodeLibrary
      @GameCodeLibrary  4 місяці тому

      Thank you!! I’m glad you enjoyed 🙏🌅

  • @staxhinho
    @staxhinho 5 місяців тому +1

    Thank you, you showed me where to get very complete template assets, made me use flip and how to jump. Thank you again :D.

  • @Zegley19
    @Zegley19 Рік тому +1

    Hey - looks good! Cool use of the asset pack

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому

      Thank you!! Your assets are all so cool - I had to use one in a vid! :-)) Thank you for your cool assets!

    • @John-dz8js
      @John-dz8js 6 місяців тому

      I've used this same asset. I'm still somewhat new, I was using it for tinkering around and figuring out character movement. @zegley thanks for the cool assets. @GameCodeLibrary but I never even considered painting over them, that is clever. Thanks for the video.

  • @DlfrexDev
    @DlfrexDev 7 днів тому +1

    this is amazing tutorial thanks for your effort❤❤❤

    • @GameCodeLibrary
      @GameCodeLibrary  7 днів тому +1

      You’re welcome I’m so glad you liked it!!

  • @superiorm1rage
    @superiorm1rage Рік тому

    Thank you for the video! Cant wait for more.

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +1

      You’re welcome I’m glad you enjoyed it!! I try to post one every week, haven’t missed one yet 🫡🙌

  • @Vulcan阿修羅6498
    @Vulcan阿修羅6498 3 місяці тому

    This is getting out of subject but I am in love with your voice 🙌

  • @bluzenkk
    @bluzenkk Рік тому +1

    [wears helmet] i'm very thankful for any YTubers dev creating contents like this.
    not complain, just suggeting:
    If this vid was relese 10 years ago, I bet it will catch alot of views. but nowdays YT has alot of these Unity beginner series. so I would suggest either make intermediate level tutorials or publish videos daily so your channel won't be at the bottom of the UA-cam algorithm list. Otherwise, you wont get much satisfaction result. Content creators should understand that viewers will only subscribe when they find the information very useful and unique to them.
    also, its worth methioning that if you are doing pixel art animation, you might want to introduce the unity semi-official aseprite pack that will auto make the animator and clips for you using the tags in aseprite.

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +4

      Yes I plan on doing more advanced and unique stuff! For my own sake of learning how to edit vids and having a library of easier content to reference viewers back to, I started with beginner stuff.
      I’m a full time senior dev when I’m not making UA-cam vids, so I won’t be able to do one a day! 😝
      I appreciate your views and suggestions!! I’m in no rush to get lots of views, I’m enjoying creating lil vids for now 😇
      I have a list of almost 100 video plans though!! So hopefully some of those are more interesting for everyone!

  • @tegnevincent498
    @tegnevincent498 4 місяці тому +1

    this was amazing, learnt a lot. When moving my character it seems to tilt over in the direction I move. Anyone have a fix for this?

    • @GameCodeLibrary
      @GameCodeLibrary  4 місяці тому

      On the rigid body click freeze Z rotation!

    • @tegnevincent498
      @tegnevincent498 3 місяці тому

      @@GameCodeLibrary I noticed that! thanks anyways I am watching your tutorial on menu and inventory. Just started my game dev journey 1 week ago. I appreciate your videoes very much

  • @Tariqalzidan
    @Tariqalzidan 7 місяців тому

    i have a problem i cannot jump and use the animation to the left side

  • @JJJTHE3RD
    @JJJTHE3RD 8 місяців тому

    I'm not sure what went wrong I followed the video exactly and now my player moves but his body swaps the the other direction (i.e. if they are moving to the left their body will be facing right etc)

    • @GameCodeLibrary
      @GameCodeLibrary  8 місяців тому

      You default sprite must have been the opposite to mine! In your sprite renderer you can tick the 'flip X' option and it'll be an easy fix :p

  • @Cerowsee
    @Cerowsee 6 місяців тому

    What would I have to do to make the sprite not flip during my idle animation.

  • @majkel256
    @majkel256 7 днів тому

    So nice tut, Great work. But after adding animation my player stop jump, with 0 errors 😣😖

    • @majkel256
      @majkel256 7 днів тому

      Find Answer: I had !isGrounded in my "if(Input.GetButtonDown("Jump") && isGrounded)"

  • @KillAllCommies2
    @KillAllCommies2 3 місяці тому

    What if you have another idle animation for the character in the other direction?

  • @AsyaKlcaslan
    @AsyaKlcaslan 2 місяці тому

    Hi really good video thank you so much, but I have a question my character is flipping when I try to jump on a corner platform.Can you guys help me ?

    • @flynn1545
      @flynn1545 Місяць тому

      Could you elaborate on the problem with details and your code?

  • @iamgold3nn
    @iamgold3nn 3 місяці тому +3

    everytime I jump after it plays the falling animation it plays the jumping animation right after then goes to idle, the movement animations work fine

    • @whoisthemetro
      @whoisthemetro Місяць тому +1

      I’m having a difficult time issue where my character jumps but the animation doesn’t play. Everything else works fine.

    • @iamgold3nn
      @iamgold3nn Місяць тому +2

      @whoisthemetro make sure the exit time matches the animation length, it worked for me

    • @whoisthemetro
      @whoisthemetro Місяць тому

      @@iamgold3nn I'll have to give it another shot. Thanks!

  • @accessplayerYT
    @accessplayerYT 8 місяців тому

    It was great thanks. But my characters not rotating when I turn what soupd I do

    • @GameCodeLibrary
      @GameCodeLibrary  8 місяців тому

      This is a simple movement script:
      public class PlayerMovement : MonoBehaviour
      {
      float horizontalInput;
      float moveSpeed = 5f;
      Rigidbody2D rb;
      SpriteRenderer spriteRenderer;
      void Start()
      {
      rb = GetComponent();
      spriteRenderer = GetComponent();
      }
      private void FixedUpdate()
      {
      horizontalInput = Input.GetAxis("Horizontal");
      spriteRenderer.flipX = horizontalInput > 0;
      rb.velocity = new Vector2(horizontalInput * moveSpeed, rb.velocity.y);
      }
      }
      This bit in FixedUpdate flips the sprite:
      spriteRenderer.flipX = horizontalInput > 0;
      You can do it like that, or! Follow along at the timestamp I've linked in this video - which is the previous video of this one :-)
      ua-cam.com/video/pYu36PLmdq0/v-deo.html

  • @makoa316
    @makoa316 8 місяців тому

    how can i flip the animation? like when he walk to the right or tho the left?
    tanks for the video

    • @GameCodeLibrary
      @GameCodeLibrary  8 місяців тому

      This is a simple movement script:
      public class PlayerMovement : MonoBehaviour
      {
      float horizontalInput;
      float moveSpeed = 5f;
      Rigidbody2D rb;
      SpriteRenderer spriteRenderer;
      void Start()
      {
      rb = GetComponent();
      spriteRenderer = GetComponent();
      }
      private void FixedUpdate()
      {
      horizontalInput = Input.GetAxis("Horizontal");
      spriteRenderer.flipX = horizontalInput > 0;
      rb.velocity = new Vector2(horizontalInput * moveSpeed, rb.velocity.y);
      }
      }
      This bit in FixedUpdate flips the sprite:
      spriteRenderer.flipX = horizontalInput > 0;
      You can do it like that, or! Follow along at the timestamp I've linked in this video - which is the previous video of this one :-)
      ua-cam.com/video/pYu36PLmdq0/v-deo.html

  • @numberonebuzzfan4964
    @numberonebuzzfan4964 4 місяці тому

    Hello! These past few tutorials have worked great for my project, but now I'm having a slight issue: because my Jump animation is both a Jump & Fall animation, the game won't let the Jump animation end when I press the jump button, instead looping the last frame. I can still move, but the other animations won't play. How do I fix this?

    • @GameCodeLibrary
      @GameCodeLibrary  4 місяці тому +1

      I have another video on platformer animations where I do it slightly differently!
      ua-cam.com/video/vFYQ3Ge4XvY/v-deo.html
      At this time stamp ^ is the jump to fall transition. It then goes fall to idle. I think you could remove the fall here and replace it with jump, meaning it goes from jump to idle! (If that makes sense :p)
      Hopefully this can help you out!! :-)

  • @mollylochrie4755
    @mollylochrie4755 Рік тому +1

    Great and very clear tutorial!!! I love your skeddadling cat man! Just wondering if there’s an alternative to the Math.Abs??? My unity isn’t accepting it for some reason :(

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +2

      I'm glad you enjoyed it!!
      That's strange for Math.Abs not to work...
      What it does is flip a negative number to a positive - if it is negative.
      Instead you can check if the number is less than 0 then do *-1
      E.g:
      if(myNumber < 0)
      {
      myNumber = myNumber * -1;
      }
      Hope this helps!

    • @mollylochrie4755
      @mollylochrie4755 Рік тому

      thank you so much!!!
      @@GameCodeLibrary

  • @zoelevil7416
    @zoelevil7416 5 місяців тому

    Huge thanks for your tutorial!! :) unfortunately I ran into a little problem in the end... when my Player is landing on a platform after jumping, shortly bevor he goes from fall into idle, he does one quick jump again for a second or so, and I can't tell why this is happening... help

    • @maxinepalmerson7991
      @maxinepalmerson7991 4 місяці тому

      I am having the same problem, can't seem to work out where the issue is. Mine is also playing a few extra frames in the middle of falling so the whole jump/fall looks quite glitchy. Did you have any luck solving this?

    • @zoelevil7416
      @zoelevil7416 4 місяці тому

      @@maxinepalmerson7991 I solved it by using the code from another tutorial, there's this 2D-game-tutorial-series with the orange little player on youtube (I forgot the name of the channel but u should find it quickly). You could also try to make the collider a bit bigger at the bottom so that it detects collision earlier.

  • @doctorrooshy2588
    @doctorrooshy2588 2 місяці тому

    There is a problem i can't jump after i put the animation codes i tried pressing space but it didnt jump what should I do? Also good tutorial!

    • @GameCodeLibrary
      @GameCodeLibrary  2 місяці тому

      As I can’t see your code all I can suggest is to watch the video and check you’ve done all the steps! Or check against the free code I gave :-)
      Everything to get it working is in the video!

  • @Nomskiss
    @Nomskiss 7 місяців тому

    You don't actually have to save each frame as its own png.
    You can create a spritesheet and then cut it into individual cells using Unity's sprite editor.

    • @GameCodeLibrary
      @GameCodeLibrary  7 місяців тому

      Yeah I’ve done that in my other videos 😝 that’s the shame about my oldest video getting the most views!! It’s my worst one lol!

  • @EVRYTHING2000
    @EVRYTHING2000 10 місяців тому

    can you show us how you copy animation from asperite to your cat character?

  • @nishitakulkarni9703
    @nishitakulkarni9703 3 місяці тому

    Perfect tutorial! Thank you!!

  • @glowraptor5228
    @glowraptor5228 5 місяців тому

    quick question, when i hit the ground, my character does not go back into movement, it just plays the "jump" animation over and over no matter what i do. any suggestions?

  • @Force5_Eye_Dev
    @Force5_Eye_Dev Рік тому

    Excellent video.

  • @Elaoz
    @Elaoz 6 місяців тому

    beautiful job

  • @kadamnable
    @kadamnable Рік тому +1

    cute sprite great video!!

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +1

      Thank you!!! I’m thinking of making a mini cat burglar game inspired by the sprite I think that’d be fun!

  • @kozmobotgames
    @kozmobotgames Рік тому

    Amazing tutorial! I have already made two games that are available on the Play Store 😀

  • @qzlocx
    @qzlocx 7 місяців тому

    i cant drag sprites to the animation window

    • @GameCodeLibrary
      @GameCodeLibrary  7 місяців тому

      Make sure you've got your player selected in the hierarchy and that you're dragging in the individual sprites! Can't think of another otion it might be 🤔

  • @GameCodeLibrary
    @GameCodeLibrary  10 місяців тому

    ❗❗❗😱📢 50% OFF LAUNCH SALE!! 😱👾❗❗❗
    BUY THE COMPLETE GAME TEMPLATE NOW!!!
    gamecodelibrary.itch.io/2d-platformer-template

  • @gnomewarlord7128
    @gnomewarlord7128 6 місяців тому +1

    You're my favourite amongst the british "people"

    • @derekfelton1668
      @derekfelton1668 3 місяці тому +2

      Can I just remark how odd it is that you put "people" in quotation marks?

  • @FakeMonika
    @FakeMonika 7 днів тому

    The assets pack is no longer free :(

    • @GameCodeLibrary
      @GameCodeLibrary  3 дні тому

      Ahh thats a shame!! There are lots of free options on itch.io you can check out and can use for this tutorial! I'll update my description to say it's no longer free, thank you :-)

  • @BeyondEyesight-eh1gn
    @BeyondEyesight-eh1gn 11 місяців тому +1

    so the code is NOT there for free?

    • @GameCodeLibrary
      @GameCodeLibrary  11 місяців тому

      It is:
      www.patreon.com/posts/2d-platformer-83575703

  • @pixlerin
    @pixlerin Рік тому +1

    Good job, great video! Will you do 2d top-down tutorials in the future?

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +2

      Yes I will! Top down is my favourite way to make games since you can do so much with it. I have over 70 video ideas planned 😂 covering the basics with platformer first since it’s simplest!
      Thanks so much!

    • @pixlerin
      @pixlerin Рік тому +1

      @@GameCodeLibrary wow cool! Looking forward to all of them 😄

  • @childtaker318
    @childtaker318 18 днів тому

    Does this work if you use krita

  • @ines4728
    @ines4728 Рік тому

    love your videos!!!

  • @EpicHashTime
    @EpicHashTime Рік тому

    Excellent tutorial

  • @zzzzzaaaa9999
    @zzzzzaaaa9999 3 місяці тому

    Damn I'm such a noob. Everything looks different on my end and this tutorial is too fast to follow. I also don't have the same settings and options. Is she using some old version of Unity?

    • @GameCodeLibrary
      @GameCodeLibrary  3 місяці тому

      I have a playlist where I go a lil slower and go through the whole creation of a platformer game here if you're interested! It's slightly newer too so may have similar options that you see.
      ua-cam.com/play/PLaaFfzxy_80EWnrTHyUkkIy6mJrhwGYN0.html
      I also have a top down series I'm starting and the animation video for that one is much much slower than the rest!
      ua-cam.com/video/82U4ToJU-28/v-deo.html

  • @fahripraz
    @fahripraz Рік тому

    your voice is very good for explanation

  • @oddysy1880
    @oddysy1880 7 місяців тому

    did you manually paint over every frame for every single animation lol? im new to aesprite and feel like theres gotta be a faster way

    • @GameCodeLibrary
      @GameCodeLibrary  7 місяців тому +1

      Yes I did! You can copy and paste certain bits to other frames like the face and ears etc :p then just move it to the right position for that frame! Sprite animation is a time consuming art!
      But there are lots of free and paid for assets you can use on sites like itch.io. So you can check those out for free easy ones! :-)

    • @oddysy1880
      @oddysy1880 7 місяців тому

      @@GameCodeLibrary this video actually inspired me to draw my own, its been time consuming, but definitely worth it for a passion project. thanks for your response!

  • @jawavoncherie
    @jawavoncherie Рік тому

    Thank you

  • @riziqhabibixiimm1498
    @riziqhabibixiimm1498 7 місяців тому +1

    Amazing video I love this, But I found some problems here, I have followed the tutorial and have confirmed that it is correct, but when the character is in jump and ground conditions, The character does not want to return to the idle position, Did I miss something?

    • @GameCodeLibrary
      @GameCodeLibrary  7 місяців тому

      If you look in your animator window while this problem happens, you can check the parameters values and see if something is wrong. You can also check the transitions to see why it’s not returning to idle. Hope you can find the issue!

  • @Rivaldix12
    @Rivaldix12 9 місяців тому

    My character doesnt jump :(((

    • @Rivaldix12
      @Rivaldix12 9 місяців тому

      maybe its about my input manager settings? i dont know :(

    • @GameCodeLibrary
      @GameCodeLibrary  9 місяців тому +1

      If you follow along with the previous video and then this one, it’ll definitely work! :-)

    • @Rivaldix12
      @Rivaldix12 9 місяців тому

      @@GameCodeLibrary thank you its working right now :)

    • @asethipro4952
      @asethipro4952 6 місяців тому

      @@Rivaldix12 Hi, Im having the same issue can you tell me what you changed so that i can too? Thank you so much.

    • @AsyaKlcaslan
      @AsyaKlcaslan 2 місяці тому

      @@asethipro4952 did you solve it

  • @parthchavan5542
    @parthchavan5542 11 місяців тому

    Thx so much :)

    • @GameCodeLibrary
      @GameCodeLibrary  11 місяців тому

      You’re welcome! I’m glad you enjoyed 🙏

  • @blackpop654
    @blackpop654 Рік тому

    what software did you use to implement the sprite assets and create your sprite?

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +1

      I used Aseprite! I use the free version, but you can buy it online too.

    • @blackpop654
      @blackpop654 Рік тому

      @@GameCodeLibrary thank you 🥰

    • @arabiwasabi
      @arabiwasabi Рік тому

      @@blackpop654it’s also on Steam which is pretty neat and is currently on sale

    • @blackpop654
      @blackpop654 Рік тому

      @@arabiwasabi i just got it off pirate bay but thanks

    • @arabiwasabi
      @arabiwasabi Рік тому

      @@blackpop654 sure, that's also a way to do it

  • @iam_river
    @iam_river Рік тому +1

    Sorry I keep bothering you 😅 When I edited the code for animation, it sent 2 errors.
    'Animator' is a type but is used like a variable
    The name 'Math' does not exist in the current context
    I think it's something I wrote. Do you think it's possible to give me the code that I can copy and paste?

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому

      Hi no problem!
      I have the script and package for free on my Patreon :-)
      www.patreon.com/posts/2d-platformer-83575703

    • @iam_river
      @iam_river Рік тому

      @@GameCodeLibrarythank you!!

  • @consogamer1474
    @consogamer1474 4 місяці тому

    wt hill , i love your voice

  • @Tryicky
    @Tryicky 6 місяців тому

    Будто бы в видео не полный код.

    • @GameCodeLibrary
      @GameCodeLibrary  6 місяців тому

      I start with the code from this video:
      ua-cam.com/video/pYu36PLmdq0/v-deo.html
      The rest of the code is in the video!
      The full package is also on my Patreon for free if you wanna grab it and see

    • @Tryicky
      @Tryicky 6 місяців тому

      @@GameCodeLibrary А можете подсказать почему когда я управляю объектом, с помощью кода для перемещения, то постоянно в рандомные моменты персонаж резко останавливается, и не продолжает двигаться вперед, почему?

  • @Userrrrrrrrrrrttttttttttrttrt
    @Userrrrrrrrrrrttttttttttrttrt Рік тому +2

    It's not working😭

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +2

      I have the package and script free on my patreon for you to check out :-)) hopefully you can find a fix!

    • @BeyondEyesight-eh1gn
      @BeyondEyesight-eh1gn 11 місяців тому

      free for 9 dollars @@GameCodeLibrary

  • @BeyondEyesight-eh1gn
    @BeyondEyesight-eh1gn 11 місяців тому +1

    very fuccin nice

  • @اللاعب_الأحمر
    @اللاعب_الأحمر Рік тому

    😍

  • @хле6-ц8б
    @хле6-ц8б 24 дні тому

    Bit unrelated but your voice is really cute.

  • @BeyondEyesight-eh1gn
    @BeyondEyesight-eh1gn 11 місяців тому

    did the whole thing just to learn that i need to join your patreon to unlock the code smh

    • @GameCodeLibrary
      @GameCodeLibrary  11 місяців тому +2

      The previous video showed you how to do the code - and the code and entire animation package is on my patreon for free my bro:
      www.patreon.com/posts/2d-platformer-83575703
      Living up to the username of beyond eyesight lol 🙂
      I also show months worth of work for free in all my tutorials - I get nothing for doing this!
      Talk about a waste of my time for the sake of kindness hey!

    • @BeyondEyesight-eh1gn
      @BeyondEyesight-eh1gn 11 місяців тому

      im sorry i was in a bad mood that day
      @@GameCodeLibrary

  • @E_locked
    @E_locked 9 місяців тому

    PLS SPEAK LOUDER

    • @GameCodeLibrary
      @GameCodeLibrary  9 місяців тому

      Lol I have a new mic since this video, hopefully I’m loud enough now 🥲🙏