While other youtubers are asking for a fee for their 2D character controllers, you actually made yours accessible for everyone to try out and i must say i really respect that a lot and appreciate the time and effort to help developers out there in need of stuff like these. To even make things better, your code is very clean and readable and commented.. thanks so much.. you just earned yourself a subscriber and a stan. Keep up the good work!!
people like you are the reason i smile at 2am after being stuck on a problem in my games. seriously, i cant thank you enough for how much information you provide and how elegantly you explain things in such a short amount of time.
Honestly I think this is one of my favorite channels, you keep things simple in a way anyone can understand, the editing is great, and the topics are always interesting. Keep up the amazing videos!
Another platfomer video, this is gonna be amazing! Also, followed your previous tutorial on forces and movement stuff, the code needed a bit of tweaking and understanding, but once everything worked, it absolutely worked. Am excited to learn more in this video as well!
Just wanted to say thank you, this is an amazing video. I felt like I wouldn't find anyone getting more specific on how to do good platformer movement, and ended up not only with someone doing so, but also showing _how_ in a great video format. There's even a demo! Props to you, this took effort and it shows.
Genuinely thank you for the extensive time and effort you put into these videos, not only doing extensive research but putting effort into making the video look good aswell. I really appreciate your work
I've watched this video beginning to end about 10 times so far (and will need to more in the future) because of how informative it is and how it really highlights key points to add into the game. I also like how it isn't a "tutorial" so you kinda need to figure out how to add it yourself allowing you viewers to become better developers by learning and problem solving.
Wow, what a video! Not only is your analysis of the movement very intuitive and well-explained, but the editing complements what you're saying really well! There is one thing that kind of bugged me though, but this is probably just a me-thing: there are so many editing effects (e.g. zooming in, switching between video and audio tracks, adding graphs on screen ...) happening in quick succession that it sometimes felt like an overload of information to me and was hard to follow, even though the explanation itself was great.
Thanks so much! I completely agree, I went a bit over the top in this video with the pacing :D So this will definitely be my primary focus for future videos. Great to hear the content still felt well-explained, thanks again!
This channel is a God send 🙌 🙏 seriously i am working on a 2d metroidvania and I know I am going to struggle with the programming aspect so thank you!!!
I've been starting my game with a more Celeste style movement but I think a hollow knight style movement may actually be better for the game I'm making.
Hello, I have a question about PlayerData. I would like to know how runAccelAmount is calculated. I would like to know your code design ideas, but I cannot understand this part. I would like to ask for advice。And thank you for your video. It's the best video I've ever seen and done so far
Hey in your previous video you recommended a circle collider for tileset games, i have a problem tho, my character keeps sliding of the tiles corners because of the circle shape, is there any way i could fix that?
Yeah, because of this I've started using a normal box collider and then making my tile maps a composite collider instead. This has worked great for me so far 👍
Your movement breakdown has really helped me get a great feeling movement. But there is one thing I have bee trying to solve for a while, with many failed attempts. That is slopes, it seems like when i get slope movemnent working i need to sacrifice someting else and I don't like that. I know how slope movement works, but with acceleration based movement that looks at speed diufference in can cause problems when forcing like jumping are applied. This isn't a problem when only doing x velocity, but for slopes there is also y velocity. Does anyone have a difinitive and clean way of inplement slopes? Thank you very much though, if slopes don't work out then I will leave it out of my game until a solution comes its way.
Thanks! But what about if the player is on a moving-platform? After moving player gameobject to child of moving-platform and add ground layer to platform, I cannot understand how to manage AddForce() to move player togheter with the moving-platform and at the same time let the player able to move on moving-platform like when the player is on normal ground. Thanks
I implemented the momentum movement from your code and I have been struggling with taming the speed when hitting a wall and keep flying off into the distance from the momentum build up and you can cause this by pressing right against a wall and then jumping over at an angle as well like wheel spinning a car or something and enemies collision boxes are equally a problem. I have two tilemap colliders one for walls and one for ground and the edge of a tower needs to be ground on top and wall on the side but that doesn't seem that possible. Additionally if I made it both it means anytime landing on an edge it would reset the speed and lose momentum which means jumping between platforms isn't as fun anymore, additionally when wall jumping if I made it lower the speed then you always jump between walls with the same speed as well. I am open to any advice on this even if I need to redo my entire walls and ground setup.
I'm having some trouble using the script, everything works great, and I've gotten the movement how I want it, so first off thank you! It's amazing that you've made it free and easy to use! Although I'm having trouble with infinite jumps, I think it's the ground check not working properly, even though I followed the github page instructions, and I'm not sure what to do as I'm too nervous to mess with the commands directly. Any clues on what might be causing it, or ideas to try to fix it?
Btw when I made a moving platform. When our character moves with the platform, it can't run. It moves really slowly. How should I fix it? I tried many things, like adding that platform linearVelocity to our character Run void but couldn't made it happen. Pls help and thank you for this great example code.
This control is beyond amazing and so adaptable. My only concern is if I wanted to add slopes into the game. I've tried a few approaches, but nothing seems to work. They just slide back down and walking up the slope is like pushing a massive boulder. Is there an easy way to get the player to move up them?
There’s an issue with this where my character is slower moving to the left and doesn’t get affected by decceleration, but the moving right works fine, any ideas?
Is anyone else having issues with wall jumping happening (despite not being against a wall) when spamming the jump key in the air? I can't figure out how to fix it
We don't need it since all our code (that is code that's running constantly such as the run) is working within the FixedUpdate method. This will always get called 50 times a second. So we don't need to worry about changing frame rates and so don't need to use time.deltaTime. If you're looking for a more detailed explanation, I'd highly recommend Jonas Tyroller's video on Delta time
@@DawnosaurDev There is still a chance that Time.fixedDeltaTime gets longer. And a day after I commented I found that RB.AddForce() is already containing Time.fixedDeltaTime inside unless you use impulse force mode
For some reason my character isn't jumping. I didn't want the slide and wall jump abilities so I neglected those codes. Apart from that I have pretty much the same code as yours but my Player won't jump. What could be wrong with my code??
Hmm, so how like to approach this is going through everything that needs to happen for the player to jump such as 1) Ground Checks 2) Input Checks 3) Variables (sometimes people forget to set key variables eg: coyote time of the jump buffer if you're using my code) etc 4) Jump Force Then work through all of these and see which ones aren't working when they should. Generally when trying to fix a jump I always start by making sure my ground check is working right and working my way through the whole system. There's loads of tiny things that might be slightly wrong so I'm sure if you do this you'll get it fixed in no time.
How is it when i try to implement the script, even in the Demo Project i can only look left and right and not experience any gravity, not be able to move or jump?
I ve set everything except Layers n Tags section I ve tried to create a layer named GroundL and then I ve changed my ground objects layer to GroundL and did the same to player movements inspecter layer value but even if I did this My player wont jump and if I change my players layer to GroundL my player can jump İnfinitely how can I adjust Layers and Tags Section Thanks for the help in advance
I ve installed the demo and almost copied everything after that other than script because it has dash and animator thingies but other than that its almos %100 still my character wont jump from ground it only does wall jump from walls how can I fix it
Hi man, thanks for the amazing video, I'm trying to implement the player data but I don't know wich are the values for the fields in PlayerData and I can't extract them from the repository. Can you help me plz with the values for Hollow knight type plzzzz :D
Thank you! Ok, so I've just uploaded images for each of the characters to the demo on itch. If you look on the right-hand side of the page below the main game window they should all be there :D dawnosaur.itch.io/platformer-movement-demo-2
hey, i'm trying to add a Gliding ability into your code but every time i put this new line of code and start the game, the character start floating with close to no gravity.
Hey I love your videos and I have learned so much from them, but I have this problem that am trying to fix for like 3 days and its driving me mad For some reason whenever I add a Physics Material 2d to the player and set the friction to 0 wall jumping doesn't work properly.. whenever I have vertical positive velocity it just doesn't jump, only at the apex of my jump or when i have negative y velocity it jumps, u have any idea what causes this or how to fix it? Again love the content, waiting for the next vid
Sadly not, my best suggestion would have to be to try debugging each part. I'd say try first checking if the ground detection is messed afterwards next best idea would be an issue with applying the jump force. Sorry this isn't a super helpful answer and for taking ages to reply. Let me know if you're still having issues and ill try and help out :D
Is there any way to "apply forces" in a kinematic character? It doens't need to be really using the ApplyForce method, it could be with another algorithm. Please do not answer "You cna't apply forces in a kniematic character"...
I've experimented a little bit with AddForce() and I believe under the hood the function performs a calculation along the lines of this: RB.velocity = new Vector2(RB.velocity.x + (Time.fixedDeltaTime * speedDif * accelRate) / RB.mass, RB.velocity.y); (this is a version of my line of code) float movement = speedDif * accelRate; RB.AddForce(movement * Vector2.right, ForceMode2D.Force); So, you could definitely try this out on a kinematic character and see how it works out :D
Hi, I´m currently learning how to make videogames i tried to update ur script to a 2.5D enviroment but i had some problems with the code so i wanted to ask if u can help me to solve them (of course i´m giving you the credit for the code)
You state that holow knight simplifies its player movement only it looks from our eye to be a limitation so to input easier coding for mechanic feed backs. Like insecurity, and incompetence exist in game design. On an empty shadow floor of the human psych. Celeste looks to own the elements both fluidity, and mechanical clunk [NOT worthy contrast insert concept] in the character movement. Dynamic-robot sure. Dynamic-panther for such a slim build? No. Ading a sugest element from your video. Responsivity when afecting movement at variable speeds, and the human sense of aceleration, and deceleration when moving on a grid scale frame. Meaning. Tai chi FOOL'S. Thanks art analytic break down; man. You help. Rare for people to help.
Hi i use the code but i get this error: Rigidbody2D.gravityScale assign attempt for 'Swordmaster' is not valid. Input gravityScale is { NaN }. UnityEngine.Rigidbody2D:set_gravityScale (single) PlayerMovement:SetGravityScale (single) (at Assets/Scripts/Swordmaster/Movement.cs:249) PlayerMovement:Update () (at Assets/Scripts/Swordmaster/Movement.cs:214)
While other youtubers are asking for a fee for their 2D character controllers, you actually made yours accessible for everyone to try out and i must say i really respect that a lot and appreciate the time and effort to help developers out there in need of stuff like these. To even make things better, your code is very clean and readable and commented.. thanks so much.. you just earned yourself a subscriber and a stan. Keep up the good work!!
wow thanks so much, that means a lot!
people like you are the reason i smile at 2am after being stuck on a problem in my games. seriously, i cant thank you enough for how much information you provide and how elegantly you explain things in such a short amount of time.
Honestly I think this is one of my favorite channels, you keep things simple in a way anyone can understand, the editing is great, and the topics are always interesting. Keep up the amazing videos!
thanks so much!
The only problem with this tutorial is that the series has only one episode. Amazing job!
Another platfomer video, this is gonna be amazing!
Also, followed your previous tutorial on forces and movement stuff, the code needed a bit of tweaking and understanding, but once everything worked, it absolutely worked. Am excited to learn more in this video as well!
Awesome, hope you loved it!
MUCH MUCH LOVE for making this public! ♥
Just wanted to say thank you, this is an amazing video. I felt like I wouldn't find anyone getting more specific on how to do good platformer movement, and ended up not only with someone doing so, but also showing _how_ in a great video format. There's even a demo! Props to you, this took effort and it shows.
Holy shit, this is exactly what I needed. I'm making a game all about movement and I'm really excited for part 2!
Awesome video! Loved the editing and the information!
Thanks.
Glad you enjoyed it!
Genuinely thank you for the extensive time and effort you put into these videos, not only doing extensive research but putting effort into making the video look good aswell. I really appreciate your work
Your videos formed almost all my knowledge on platformer mechanics. Thank you!
Who else watched this once and has been coming back for that snippet of code at 0:46
I've watched this video beginning to end about 10 times so far (and will need to more in the future) because of how informative it is and how it really highlights key points to add into the game. I also like how it isn't a "tutorial" so you kinda need to figure out how to add it yourself allowing you viewers to become better developers by learning and problem solving.
Amazing vid as always! Can't wait for part 2! ❤️
Wow your editing has really improved, it’s great well done
Wow, what a video! Not only is your analysis of the movement very intuitive and well-explained, but the editing complements what you're saying really well!
There is one thing that kind of bugged me though, but this is probably just a me-thing: there are so many editing effects (e.g. zooming in, switching between video and audio tracks, adding graphs on screen ...) happening in quick succession that it sometimes felt like an overload of information to me and was hard to follow, even though the explanation itself was great.
Thanks so much! I completely agree, I went a bit over the top in this video with the pacing :D
So this will definitely be my primary focus for future videos. Great to hear the content still felt well-explained, thanks again!
this was an amazing video, i cannot wait for pt 2!
dude.... the quality is insane, we are looking on the next GMTK channel right now!
good luck
Thank you!
This channel is a God send 🙌 🙏 seriously i am working on a 2d metroidvania and I know I am going to struggle with the programming aspect so thank you!!!
I learned something new today. Amazing video, keep it up Dawnosaur!❤✨
Ayy! Thanks a lot!
underated asf honestly this helped me sm
Very Awesome video Dawnosaur!
I'll be waiting for part 2 hehehe...
thank you so much! this was a very creative solution and it helped me a lot :)!!
love your videos, subscribed!!
Super cool video !! I really like that you mentioned N++, it’s one of my favorite platformers :D
(But hey! Maybe yours’ll be the next😄)
I was looking at part 1 yesterday, that's so weird how part 2 has been released just now.
he finally posts after almost a year!1!!!!111
ayy!!
why u have only 3,5 k of subscribers , that is amazing
Youre a fucking legend for this is there a dono link? Youre far too kind for making it publicly available
Thanks a lot!
I do! www.paypal.com/donate/?hosted_button_id=DRE69AWE76ZTN
You the GOAT, please comeback
I've been starting my game with a more Celeste style movement but I think a hollow knight style movement may actually be better for the game I'm making.
really good video keep it up
another great uploade
YAY!!
NEW VIDEOOO
OMG...take my subscription!!
Broo you just saved my LIFE👍
How would you implement having external forces?? For instance fields that add speed to your character, or bounce pads that take momentum into account?
Remember us when you get popular! +1 sub
Hello, I have a question about PlayerData. I would like to know how runAccelAmount is calculated. I would like to know your code design ideas, but I cannot understand this part. I would like to ask for advice。And thank you for your video. It's the best video I've ever seen and done so far
Hey in your previous video you recommended a circle collider for tileset games, i have a problem tho, my character keeps sliding of the tiles corners because of the circle shape, is there any way i could fix that?
Yeah, because of this I've started using a normal box collider and then making my tile maps a composite collider instead. This has worked great for me so far 👍
Oh okay, thanks! Do you have any recommendations whether i should use polygons or Outline? And any other tips in the tilemap settings department?
Still waiting for the next episode!
Your movement breakdown has really helped me get a great feeling movement. But there is one thing I have bee trying to solve for a while, with many failed attempts. That is slopes, it seems like when i get slope movemnent working i need to sacrifice someting else and I don't like that. I know how slope movement works, but with acceleration based movement that looks at speed diufference in can cause problems when forcing like jumping are applied. This isn't a problem when only doing x velocity, but for slopes there is also y velocity. Does anyone have a difinitive and clean way of inplement slopes? Thank you very much though, if slopes don't work out then I will leave it out of my game until a solution comes its way.
2:26 maybe tutorial on that effect?
yes i need this
I love this!
Thanks! But what about if the player is on a moving-platform? After moving player gameobject to child of moving-platform and add ground layer to platform, I cannot understand how to manage AddForce() to move player togheter with the moving-platform and at the same time let the player able to move on moving-platform like when the player is on normal ground. Thanks
I implemented the momentum movement from your code and I have been struggling with taming the speed when hitting a wall and keep flying off into the distance from the momentum build up and you can cause this by pressing right against a wall and then jumping over at an angle as well like wheel spinning a car or something and enemies collision boxes are equally a problem. I have two tilemap colliders one for walls and one for ground and the edge of a tower needs to be ground on top and wall on the side but that doesn't seem that possible. Additionally if I made it both it means anytime landing on an edge it would reset the speed and lose momentum which means jumping between platforms isn't as fun anymore, additionally when wall jumping if I made it lower the speed then you always jump between walls with the same speed as well. I am open to any advice on this even if I need to redo my entire walls and ground setup.
I'm having some trouble using the script, everything works great, and I've gotten the movement how I want it, so first off thank you! It's amazing that you've made it free and easy to use! Although I'm having trouble with infinite jumps, I think it's the ground check not working properly, even though I followed the github page instructions, and I'm not sure what to do as I'm too nervous to mess with the commands directly. Any clues on what might be causing it, or ideas to try to fix it?
did you solve the problem I am having some what same I think my problem is related to layers
Btw when I made a moving platform. When our character moves with the platform, it can't run. It moves really slowly. How should I fix it? I tried many things, like adding that platform linearVelocity to our character Run void but couldn't made it happen. Pls help and thank you for this great example code.
Great tutorial but is their a way to cap the speed so that it doesn't keep on increasing
This control is beyond amazing and so adaptable. My only concern is if I wanted to add slopes into the game. I've tried a few approaches, but nothing seems to work. They just slide back down and walking up the slope is like pushing a massive boulder. Is there an easy way to get the player to move up them?
There’s an issue with this where my character is slower moving to the left and doesn’t get affected by decceleration, but the moving right works fine, any ideas?
Is anyone else having issues with wall jumping happening (despite not being against a wall) when spamming the jump key in the air? I can't figure out how to fix it
also, What's the use of "jumpHangGravityMult" and "jumpHangTimeThreshold", and which valors should i give to them?
Why isn't Time.deltaTime used in acceleration code?
We don't need it since all our code (that is code that's running constantly such as the run) is working within the FixedUpdate method. This will always get called 50 times a second. So we don't need to worry about changing frame rates and so don't need to use time.deltaTime.
If you're looking for a more detailed explanation, I'd highly recommend Jonas Tyroller's video on Delta time
@@DawnosaurDev There is still a chance that Time.fixedDeltaTime gets longer. And a day after I commented I found that RB.AddForce() is already containing Time.fixedDeltaTime inside unless you use impulse force mode
I have a change animation function. Where in a movement script like this do I put the animation changes?
For some reason my character isn't jumping.
I didn't want the slide and wall jump abilities so I neglected those codes.
Apart from that I have pretty much the same code as yours but my Player won't jump.
What could be wrong with my code??
Hmm, so how like to approach this is going through everything that needs to happen for the player to jump such as
1) Ground Checks
2) Input Checks
3) Variables (sometimes people forget to set key variables eg: coyote time of the jump buffer if you're using my code)
etc
4) Jump Force
Then work through all of these and see which ones aren't working when they should. Generally when trying to fix a jump I always start by making sure my ground check is working right and working my way through the whole system. There's loads of tiny things that might be slightly wrong so I'm sure if you do this you'll get it fixed in no time.
@@DawnosaurDev I will try that.Thx
@@DawnosaurDev it seems the problem was that I set the value of jumpForce to 8 inside the code. I removed it and now everything works fine.
@@DawnosaurDev How do you suggest I write my ground checks?
Can I use this in my game? (proper commercial game) what license is this?
How is it when i try to implement the script, even in the Demo Project i can only look left and right and not experience any gravity, not be able to move or jump?
I had a doubt
I am an bigner with coding,
I wanted to use this to make my fps controller how can I do it
Pls help
I ve set everything except Layers n Tags section I ve tried to create a layer named GroundL and then I ve changed my ground objects layer to GroundL and did the same to player movements inspecter layer value but even if I did this My player wont jump and if I change my players layer to GroundL my player can jump İnfinitely how can I adjust Layers and Tags Section Thanks for the help in advance
I ve installed the demo and almost copied everything after that other than script because it has dash and animator thingies but other than that its almos %100 still my character wont jump from ground it only does wall jump from walls how can I fix it
Hi man, thanks for the amazing video, I'm trying to implement the player data but I don't know wich are the values for the fields in PlayerData and I can't extract them from the repository. Can you help me plz with the values for Hollow knight type plzzzz :D
Thank you! Ok, so I've just uploaded images for each of the characters to the demo on itch. If you look on the right-hand side of the page below the main game window they should all be there :D
dawnosaur.itch.io/platformer-movement-demo-2
what should the value of accelerate be ideally?
hey, i'm trying to add a Gliding ability into your code but every time i put this new line of code and start the game, the character start floating with close to no gravity.
Is there any easy way to make it work on mobile input?
Hey I love your videos and I have learned so much from them, but I have this problem that am trying to fix for like 3 days and its driving me mad
For some reason whenever I add a Physics Material 2d to the player and set the friction to 0 wall jumping doesn't work properly.. whenever I have vertical positive velocity it just doesn't jump, only at the apex of my jump or when i have negative y velocity it jumps, u have any idea what causes this or how to fix it?
Again love the content, waiting for the next vid
Sadly not, my best suggestion would have to be to try debugging each part. I'd say try first checking if the ground detection is messed afterwards next best idea would be an issue with applying the jump force. Sorry this isn't a super helpful answer and for taking ages to reply. Let me know if you're still having issues and ill try and help out :D
Put a capsule collider
Hi! Can you update your 2d platformer character controller for Input System?
I'm making a proper commercial video game, can I use your code in it?
of course, I will give credit to you in the game
Yeah of course, let me know when you release anything I'd love to check it out
Is there any way to "apply forces" in a kinematic character? It doens't need to be really using the ApplyForce method, it could be with another algorithm.
Please do not answer "You cna't apply forces in a kniematic character"...
I've experimented a little bit with AddForce() and I believe under the hood the function performs a calculation along the lines of this:
RB.velocity = new Vector2(RB.velocity.x + (Time.fixedDeltaTime * speedDif * accelRate) / RB.mass, RB.velocity.y);
(this is a version of my line of code)
float movement = speedDif * accelRate;
RB.AddForce(movement * Vector2.right, ForceMode2D.Force);
So, you could definitely try this out on a kinematic character and see how it works out :D
@@DawnosaurDev Thanks! I'll try that and reply here about the result!
@@gabrieldesouza112 Awesome!
Hi, I´m currently learning how to make videogames i tried to update ur script to a 2.5D enviroment but i had some problems with the code so i wanted to ask if u can help me to solve them (of course i´m giving you the credit for the code)
pizza tower: hold my toppin
yeahhh !!!
man your videos are too fast!
You state that holow knight simplifies its player movement only it looks from our eye to be a limitation so to input easier coding for mechanic feed backs.
Like insecurity, and incompetence exist in game design.
On an empty shadow floor of the human psych.
Celeste looks to own the elements both fluidity, and mechanical clunk [NOT worthy contrast insert concept] in the character movement.
Dynamic-robot sure.
Dynamic-panther for such a slim build?
No.
Ading a sugest element from your video.
Responsivity when afecting movement at variable speeds, and the human sense of aceleration, and deceleration when moving on a grid scale frame.
Meaning.
Tai chi FOOL'S.
Thanks art analytic break down; man.
You help.
Rare for people to help.
Pro tip: do *not* use forces for a character controller.
I died
Hi i use the code but i get this error:
Rigidbody2D.gravityScale assign attempt for 'Swordmaster' is not valid. Input gravityScale is { NaN }.
UnityEngine.Rigidbody2D:set_gravityScale (single)
PlayerMovement:SetGravityScale (single) (at Assets/Scripts/Swordmaster/Movement.cs:249)
PlayerMovement:Update () (at Assets/Scripts/Swordmaster/Movement.cs:214)