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.
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?
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!
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.
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
its a nice tutorial, but using physics for 2d collisions is not efficient, physics is very expensive...you should use tiled based collisions instead...
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)"
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
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.
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.
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.
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!
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
@@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 ;)
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
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*
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.
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
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.
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
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!
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?
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.
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.
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?
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!
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"
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!
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
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.
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.
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
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; }
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!
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.
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!!!!!
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:(
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.
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????
@@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 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.
@@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 ?
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.
@@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
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!!!!!!!
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
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!)
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
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.
@@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.
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!
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.
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
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
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.
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!
For some reason the idle transitions to crouching animation without me pressing anything. The "isCrouching" Parameter keeps going On and Off automatically :(
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
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!
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)
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
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
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.
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!
"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
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 { }"
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"
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?
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
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.
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)
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
oh boy, if it took brackeys 20 minutes, im gonna be here till tomorrow
SAAAMEE
Good one
no brackeys can do it in 5 minutes but he explains while showing you stuff to do
what 1 day? wow thats fast i am here for a month
Same
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.
(and also make sure your ground check is outside of your bottom collider)
thanks this really saved me from insanity xd
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?
@@harshitpal4996 do you have it set to play in the animator controller and have the animation triggered by script like in the video?
Thanks!! you saved me :)
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!
Thanks :)
Thank you very much :D
Tx
(130)
Nailed it, however it is line 130.
m_Grounded = true; // note: this was false when downloaded from Brackeys.
My man left RUclips years ago, still the best tutor out there. Thanks for all you have done Brackeys:)
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.
Thanks a lot, you rescued me
Thank you for the tip, but mine still seems to be trying to activate both without pressing anything...
i don't know if you still alive but you saved me after hour of suffering
when i click on "what is ground" they dont show me uncheck option how i uncheck player layer?
what a champ
once again brackeys has the simplest and most effective solution - we miss you boss!
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
Yea true
most effective - kill me
@@jood7449 if i were you id join the discord if you haven’t. Theres a bunch of smart ppl that will help.
its a nice tutorial, but using physics for 2d collisions is not efficient, physics is very expensive...you should use tiled based collisions instead...
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)"
Bro, TYSM you saved my life
Thank you so much!
Thanks mate, this is what i was looking for
THANK YOU. U R A LEGEND 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
And you also need to check off (can transition to self ) on the transition from anyState
I would be lost without Brackeys, thank you for everything you have done
If you would only have known
@@Officergizmo lol
Please tell me how you add character controler
@@magiclessbrat8501 its complicated
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
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.
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.
I couldn't figure out the first one, but the ground radius variable worked!
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.
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!
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
Thank you so much
thank youuu
thank you buddy
thx
you saved me thanks
Thy master shall be remembered
thanks for the experience brackeys
4 months of you gone is like a decade to me
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
Thank you so much!
I saw it...
in 2023
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.
Skeletal animation would be so helpful and it looks quicker too
It is less quality, of course.
Not Enough Horror. It seems it would be good for a 2D physics based fighting game like the one Im gunna try make
Both have their pros and cons, you cannot get a pixel style like in this video with skeletal animation
actually you can , look for Dead Cells
sprite swap is the best for pixelarts though.
i miss this channel
sameee😭😭
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"
thank you so much couldn't figure it out
@@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
@@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 ;)
Thank you so much, this really helped!
Thanks a lot! I couldnt find it either, but your comment helped :)
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
Thank you so much
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*
Thank you, this helped a lot!
I love these tutorials, they are the only reason i know how to do remotely anything in UNITY
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.
@Bobby5z0 you bastard xd
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
Thank you
thanks bro!
Thank you so much life saver!
Thanks a Lot ! yes Please skeletal animation would be so helpful ! ( Like if you agree ) !
?
yeah,,..,. ?
Sans
Cristian the great toast because sans
@Cristian the great toast he has to do with everything
Please do game saving/loading tutorial!!
Just use player prefs
He made a video about saving and loading high score
I mean about saving and loading if you exit the game and you want to continue playing later ..
Yea same technique
or you can use save game free (it is very helpful in my eyes)
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.
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
Thanks! I almost quit after I couldn't find it
I love you so much
The problem - everything.
The soloution -
cry
20 mins for Brackeys to do jumping animation.
It took me 2 whole hours to solve all the problems.
bool meCrying = true;
And i have no idea how to play cutscenes.
Cry==1
If Cry == 1:
Print("big sad')
@@kacpercicharski4193 brackets also has a vid on that
Brackeys**
@@kacpercicharski4193 also the syntax in that is preeeetty wrong 😬
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!
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?
I'm Confused same
Same here.. :/
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.
Ted Alden-Templeman it didnt work
(And do you know why the idle animation & crouching animation play both at the same time)?
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.
I would LOVE a video on anima 2d
Incredibly easy and clear! Definitely you are the best tutorial channel about Unity!
If your jump animation keeps looping, go to your jump->idle transition and change the parameter to "Speed Less Than .01" :)
Didn't work 😭
you.are.the.best... literally saving my school semester XD
Lol, you, lol school
All of your Unity tutorials are absolutely amazing, they've been helping me so much in learning game development! Keep up the great work!
i love it, just recently bought the aseprite and im willing to make my own videogame, these videos are a lot of help! ♥
finally, after the error are occurrence. I can make animation for my character. Thank you so much Brackey.
The great thing is that you keep your *smile* _visible>true_ in all your videos...keep going!
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?
@animeharmonics Thank You!!!
Yo same
@animeharmonics It didn't work for me
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!
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"
thank you so much
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!
Thanks!
Thanks!
Nice one! Found a new bug though, haha.
Yay! This one finally worked!
Thx
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
omfg thank you!
Oh my gosh this literally saved my sanity!!! Thanks for the tip
woahh thank you!
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.
thanks a lot you are a saviour!
the only tutorial that actuallly helped me even 2021
please help me! Why i need to double press the UP/W key to see the animation of jumping?
Same for me :(
me to
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.
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
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;
}
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.
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!
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.
im using my own script and was wondering if anyone knows how to add the events to my character controller
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!!!!!
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!!
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:(
I need learn more coding and this is a great vid
he made a C# series. you should watch it
jack you*
one of my favourite videos!
I'm crying my character is walking and moving and ahsjdkgashjfgfj THANK YOU
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.
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????
@@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.
I have a problem with my scripts that are not reconized, i can not join it to the inspector
@@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.
@@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 ?
I miss you, Brackeys
Your tutorials are so helpful. I would love to see a skeletal animation one! Thanks for your hard work.
Thank you so much, this is saving me during my platform design final.
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.
my jump animation plays for like 0.0001 seconds because it touches the ground when i jump how do i fix this?
When I have the Character Controller 2D script open the events show, and I can’t access them. What should I do?
in this Prohect New Script
You want to press the plus sign and then drag your player movement script inside of your event.
how do i add events?
i am having the same issue now
but i cant see any events at all under the script
We miss you Brackey😔😔😔😔
You never explained events in the character controller script
Right? He just said he added some code like its not important but its missing for me.
@@Jason_fox buckaroo he added it to the character controller script. He wasnt talking about the current script
@@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
@@Jason_fox ty dude i tought i had the most recent script (thumbs up)
@@jerzyfice1426 Wait, what? Where can I find the new script?
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!!!!!!!
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
Thank's !
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!)
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
@@ashtimbog whpa 8 hours ago
@@someobscuremusicchannel lol 3 hours ago
@@Liquid23 ee 14 minutes ago
@@someobscuremusicchannel hddeuebhe 2 minutes ago
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.
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.
Thanks a lot! you saved me a lot of trouble! \(*o*)/
@@middlemarv Can u tell me how to do this?
@@yuratwitch1093 I can and will. Give me 20 mins.
@@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.
omg!! thanks Bucky the ".anim" extension was missing in my case, thanks!!
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!
Omg thank you savior from the heavens
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.
it still doesn't seem to work ._.
move the ground check under the character
yeeeee
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
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
Cant think of a better way
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.
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!
We miss you legend
For some reason the idle transitions to crouching animation without me pressing anything.
The "isCrouching" Parameter keeps going On and Off automatically :(
I have the same problem.. Did you find a fix for it?
Check if your player has the "Player" layer assigned
Worked for me! Thank you :D
Also the attribute “What Is Ground” of “Character Controller 2D” need to have everything selected except for that “Player” layer
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
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!
Never mind all of this is wrong
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)
Thanks, it helped me ! :)
still doesn't work...
1. it's Upwards
2. That doesnt work as then the ground check can't detect the ground at all.
THANK YOU
THANKS
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
it needs to loop i've checked mine but the animation doesn't loop do you know why?
I appreciate you for keeping your channels on view so that we can see other good channels for this too thank you 😭
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
thanks
How do you add "Events" on a Script? i didn't use his Character Controller 2D script
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.
@@Petesails thank you thank you THANK YOU
whos back to these classics in 2024
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!
"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
check this video out it might help you : ruclips.net/video/UB1eCuM2sfE/видео.html
unity is stupid. the gameobject you created the animator for HAS TO BE SELECTED to drag sprites into the animator.
@@muhammadmohsen8732 No its not help... its same
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.
His voice is really intellectually skilled
How did you create your On Land Event in the "Character Controller 2D" Script?
Find out how yet?
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 { }"
@@emil6176 that helped a lot thanks!
@@emil6176 what do you do after that because for me its still not working i have no animation
@@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
This guy really helps.
How did you make the event for landing check ??
brackeys is the goat
Brackeys why aren't you uploading videos?
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"
Lifesaver! It takes me a lot to time to animate through code!
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?
BROOOOOOOOOOOOOOOOOOO!! JUST WHAT I NEED IT!!!!
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
oh boy.. thats really hard man. I hope you find a solution to it!
help pls my character would not do the jump animation cz the "isJumping" gets activated and deactivated in a nanosecond
Same
@@yuforea i just added an exist time to the jump animation
@@agustya4321 .
@@yuforea so did it work fine? im glad i helped
@@yuforea np
To fix any weird crouching issue add the arrows that are coming from Any State, IsCrouching = false
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.
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)
woah nice tut, Im just curious - r u usin' some extension to color ur code or u customize all of it in the vs?
I code in vs and (in default) it seems like in video, maybe you have to update it :)
Despite the fact that there are many game dev tutorials in skillshare, i still prefer brackeys LOL
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
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;
}
After i have done everything with the crouch animation
if i hold down the crouch button my animation is spazzing
As Shirshajit Singha said there`s an error in the character controller script in the line 67/69 change "!crouch" with "crouch"
@@TheNightteror Thx dude. Did save me some hours!
I dont need no skillshare I got brackeys and you cant take that away fro, jinxed it.