🎬Just launched the Sequel: ua-cam.com/video/KKGdDBFcu0Q/v-deo.html Discord: discord.gg/W5vE5WKXYH Try out the examples: dawnosaur.itch.io/platformer-examples
this is, quite literally, EXACTLY what I was looking for. I wanted to make Celeste-esque physics and didn't even have to search specifically for Celeste to find this.
Maddy has made a post on medium about how celeste physics works. It does not work using forces. It uses speed/velocity vectors to calculate movement and exact positions on a tilemap (due to it being pixel art, madeline cannot move half a pixel etc), obviously its a lot more complex than that, but I can confirm it does not use forces as such. The concept is the same however, you do want acceleration and deceleration, but you can achieve it without forces.
@@huseyinakkoc1062 The line of code in question is as follows: csharp copy code float accelRate = (Mathf.Abs(targetSpeed) > 0.01) ? acceleration : deceleration; This line of code is inside a FixedUpdate() function in Unity and is responsible for calculating the acceleration rate (accelRate) based on the target speed (targetSpeed), acceleration (acceleration) and deceleration (deceleration). Next, we will break down the line of code to understand how it works: Mathf.Abs(targetSpeed) > 0.01: This part of the code checks if the absolute value of targetSpeed is greater than 0.01. Mathf.Abs() is a static function of the Mathf class in Unity that returns the absolute value of a number. In this case, you are checking if the targetSpeed is greater than a minimum value of 0.01. This is used to determine if the object should speed up or slow down. ? acceleration : deceleration: This part of the code is a ternary operator that determines the value of accelRate based on the result of the previous condition. If Mathf.Abs(targetSpeed) > 0.01 is true, then accelRate will be equal to acceleration. Otherwise, accelRate will be equal to deceleration. In short, this line of code sets the acceleration rate (accelRate) based on the target speed (targetSpeed). If the target speed is greater than 0.01, the acceleration value is used. Otherwise, the deceleration value is used. Yeah I used ChatGPT
Well, I spent many hours looking for a good and also beginner-intermediate 2D platformer movement system for Unity and finally found this. Now this is a quality content. The video is easy to understand, and the used concepts are really well-explained. Provided github code is well documented and easy to understand with some Unity documentation digging, also great for adapting by using scriptable object for holding movement parameters. I hope you will put here more useful videos like this. :)
Let me just say man, of all the player controllers I've implemented, when I finally got this working, it is by far the best feeling controller I've ever made. I'm more of a Visual Scripting guy so it took me a little time to translate your system here, but DUDE! Thank you so much! This is now going to be my designated method for player movement! You rock!
If you like visual scripting, what you can do is making modular c# code and make specific cisual editors for your use case (I know it's hard, but it's also weirdly fun)
Man, I've been using Unity for quite a long time this is literally the BEST video I've ever seen about platformer movement. Glad youtube showed this on my homepage.
The new input system's so cool! It's not super well implemented in the code right now, but when I get round to adding some new features, I'll try to tidy it all up and make it all fit nicely :D
@@DawnosaurDev and for those who had issues like me implementing the handler and control files and movement scripts, you will need to go into Edit-> Project Settings and then Player and scroll down to the configuration section and change Active Input Handling from New or Old into "Both" in order for the current code to work.
Really nice explained. Many people which program in unity do not realize how important all of these mechanics are and you really explained all. Edit: And the fact that you explained them IN CODE. Dude you need more subs.
Finally someone who truly explains how to make proper player movement instead of making something in 20 minutes and showcasing it! Great video, very useful
I remembered seeing this video 2 times before, and I remembered it was so simple and informative. And today I am making my first game, and I wanted the controls to feel as good as possible, and then I remembered this video. I searched up something like "Video game movement analysis", and I found it!
The quality of the videos. The music and videogame taste. The smooth explaining. There's no reason NOT to be your 500th subscriber! :D Congratulations, underrated tutorial guy! And..well..thanks! XD
yo this is a really nice solution; I've always had an issue with figuring out how to get physics-based movement to not feel so sluggish, and the scaling-force-by-difference-from-target-speed thing you have here seems to work pretty well
a year late, but howly this is EXACTLY what i need. I want to make a snappy movement but I want it to still able to be affected by AddForce. Thanks a lot dude you just gained a subs!!!!
The same tutorials on UA-cam are repeated over and over again, using the same methods, and 99% of them are very basic tutorials. Professional and high-quality tutorials like this are rare and must be supported.
This needs to be said right now... This is the best video ever made on youtube, it is so helpfull and so full of information, i would pay money for this information, because im in need of movement system for my 2D Metroidvania
Hi, thank you for this video. Great to find a different way to move than the usual rb.velocity = ... Also, good to see that you use the new input system. M. D.
I just started developing and designing games 4 months ago, I'm about to tackle my first platformer in the next few weeks as my next project. This is explained so well and i understood 100% of it! I'm so proud to be able to look at the code now and understand what it means and I'm so happy to be at a point where if i do end up copying this code, it wont be blindly copy pasting it. I'm still not at the point where i can come up with things like this myself but i can definitely tweak a few things and understand the effect they have and my reasoning for them. Thank you for making this video! i subbed and I'm looking forward to watching many more of your future videos :)
thanks man. this is awesome. there are so many ways to do this but none of them feel as nice as i would like. I havent tried your way yet but it takes into account a lot of factors that i havent seen considered elsewhere. well done!
this system is FANTASTIC!! 1 question though, wondering if anyone knows. Instead of flipping the Scale on the X (or changing the "FlipX" on the Sprite Renderer) to get the player to turn around, I generally like to use transform.Rotate(0,180f,0) to get the player to turn around. That way, the actual transform.right flips, and so any children of the player also turn around properly (and saves you from having to do multiple checks on both the left and right side) However...implementing this seems to result in a VERY slight (but noticeable) jitter for a frame when the player turns around (only when in the air interestingly) - happens with or without camera follow. I'm looking for the smoothness you get from flipping the Scale on the X, but the functionality of changing the transform.right. And I don't really want to interpolate the rotation as this produces a Paper-Mario-like effect. Any ideas anyone? EDIT: solved. This seemed to be a problem when my character was in the air only (gravity using RB, therefore physics simulation) - and since I was checking for this rotation change in update, the physics vs the transform change were fighting each other that frame, resulting in the jittery motion. So the fix, IF you are wanting to change the player's transform.right directly (instead of faking it by using -1 on the x scale) - is to call the CheckForTurn() function in FixedUpdate, not Update.
I can't believe I missed this tutorial. I used to see this video pop up a lot but always assumed I'd seen it already. God damn it all. I've been squinting at my player's jump. I've gotten it down using velocity instead of add force, but there was always something off about it. Like it didn't feel natural. And the code to control things like gravity, deceleration and acceleration is really messy with velocity compared to that clean force code. Thank you.
Wow you're insane man. one of the best video I've seen from this subject. Hope you're gonna continue posting some other tuto (yea I know my english is very bad 👀)
This is a very well done tutorial! It covers a lot of ground and gives plenty of code examples for me to replicate. Thank you and keep up the good work!
i always thought i needed to use kinematic and build a whole physics system to be able to make this kind of controller. As i'm making a small project (which is basically a celeste rip-off let's be honest) this video is helping me, and will help me get a better understanding of unity physics system. you are too kind. Thanks man. i mean it.
God damn, what a video. Coding noobs are only able to experience the creative joy of game development because of amazing content like this - thank you!
Please keep making great videos like this one! They are well-edited, concise, and pack a lot of useful information in a short amount of time! Also, you explain things incredibly well!
Wow. This video is very well made and informative. Congrats dude! For some feedback, I would suggest adding some diagrams when explaining the coding parts to break up some of the visual monotony. The video flows super well, while keeping a steady pace. Subbed, fantastic job!
This is so awesome! I've been looking for a way to create a 2D platform character controller that works with Physics for a long time but just couldn't seem to find any good tutorials or examples online. I downloaded your project and was so happy at how clean and tidy the code and the scene are! Thank you so much for the amount of work you put into this! Have you thought about creating a step-by-step tutorial on how you created the code for the playerMovementImproved script?
Just realized that I never left a comment on here, anyways, this video is amazing! Everything is explained very well and the visuals really helped to explain the code. Thank you.
I finally caved and decided to just use your movement tutorial, I tried for at least 8 to get and use my own movement system through the power of knowing a highschool amount of math and physics, this one works so much better lmao, at least I tried, good work with yours and thanks
@@DawnosaurDev We are making a 2d platformer in unity for our final project in my game design class, and my game really benefited from less floaty controls
🎬Just launched the Sequel: ua-cam.com/video/KKGdDBFcu0Q/v-deo.html
Discord: discord.gg/W5vE5WKXYH
Try out the examples: dawnosaur.itch.io/platformer-examples
WTF That reply was so fast!!!
this is, quite literally, EXACTLY what I was looking for. I wanted to make Celeste-esque physics and didn't even have to search specifically for Celeste to find this.
Happy it helped!
Maddy has made a post on medium about how celeste physics works. It does not work using forces. It uses speed/velocity vectors to calculate movement and exact positions on a tilemap (due to it being pixel art, madeline cannot move half a pixel etc), obviously its a lot more complex than that, but I can confirm it does not use forces as such. The concept is the same however, you do want acceleration and deceleration, but you can achieve it without forces.
@@Verdal_JG Isn't it incorrect to say Madeline cannot move half a pixel? Since strats like ceiling pop rely on manipulating her subpixel position?
@@beri4138 forgot to specify visually, obviously subpixels exist but visually the game only uses integer values
@@Verdal_JG I didn't realize subpixels can exist visually
Wow, even though I'm not a game dev, everything was so well explained and easy to understand. Also great editing ;).
Fancy seeing you here
@@DawnosaurDev ;)
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? acceleration : decceleration; what is that ? can you explain
@@huseyinakkoc1062 The line of code in question is as follows:
csharp
copy code
float accelRate = (Mathf.Abs(targetSpeed) > 0.01) ? acceleration : deceleration;
This line of code is inside a FixedUpdate() function in Unity and is responsible for calculating the acceleration rate (accelRate) based on the target speed (targetSpeed), acceleration (acceleration) and deceleration (deceleration).
Next, we will break down the line of code to understand how it works:
Mathf.Abs(targetSpeed) > 0.01: This part of the code checks if the absolute value of targetSpeed is greater than 0.01. Mathf.Abs() is a static function of the Mathf class in Unity that returns the absolute value of a number. In this case, you are checking if the targetSpeed is greater than a minimum value of 0.01. This is used to determine if the object should speed up or slow down.
? acceleration : deceleration: This part of the code is a ternary operator that determines the value of accelRate based on the result of the previous condition. If Mathf.Abs(targetSpeed) > 0.01 is true, then accelRate will be equal to acceleration. Otherwise, accelRate will be equal to deceleration.
In short, this line of code sets the acceleration rate (accelRate) based on the target speed (targetSpeed). If the target speed is greater than 0.01, the acceleration value is used. Otherwise, the deceleration value is used.
Yeah I used ChatGPT
This is exactly what I needed! A video on advanced movement! I was having loads of issues previously, and this fixes them all! Thanks so much!
Well, I spent many hours looking for a good and also beginner-intermediate 2D platformer movement system for Unity and finally found this. Now this is a quality content. The video is easy to understand, and the used concepts are really well-explained. Provided github code is well documented and easy to understand with some Unity documentation digging, also great for adapting by using scriptable object for holding movement parameters.
I hope you will put here more useful videos like this. :)
Let me just say man, of all the player controllers I've implemented, when I finally got this working, it is by far the best feeling controller I've ever made. I'm more of a Visual Scripting guy so it took me a little time to translate your system here, but DUDE! Thank you so much! This is now going to be my designated method for player movement! You rock!
Thanks so much, that means a lot. Glad it was helpful :D
would love to see the visual script version of this!
If you like visual scripting, what you can do is making modular c# code and make specific cisual editors for your use case (I know it's hard, but it's also weirdly fun)
I was looking for something like this for days. Really well-made video.
This is perfect. Working on my first game with my son. Our movement is big standard and feels awkward. Thank you so much!
2:07 the most beautiful 4 lines of code I have seen in my life
Made me smile!
agreed
Man, I've been using Unity for quite a long time this is literally the BEST video I've ever seen about platformer movement. Glad youtube showed this on my homepage.
Wow, thanks so much! Happy it helped :D
Haven't looked at the code, but from the looks of the listed files, you are using the new Input System....thank god!
The new input system's so cool! It's not super well implemented in the code right now, but when I get round to adding some new features, I'll try to tidy it all up and make it all fit nicely :D
@@DawnosaurDev and for those who had issues like me implementing the handler and control files and movement scripts, you will need to go into Edit-> Project Settings and then Player and scroll down to the configuration section and change Active Input Handling from New or Old into "Both" in order for the current code to work.
Actually crazy how much information you put in this video while keeping it short AND understandable. Really really great video!
"accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? acceleration : decceleration;" what is this can you pls explain ı did not get it
This is very nice way of using RB but still respecting it's velocity variable by keeping it untouched.
finally a professional tutorial about unity player movement, thanks!
Really nice explained. Many people which program in unity do not realize how important all of these mechanics are and you really explained all.
Edit: And the fact that you explained them IN CODE. Dude you need more subs.
One of the highest Quailty gamedev tutorials i ever seen
FINALLY A GOOD VIDEO THAT SHOWS A DIFFERENT WAY TO MOVE, THANKS DUDE
Your video is so good that I managed to use your solution for 3D, as well as adapt your code to have momentum like Sonic games!
May I ask how you converted the Run method into 3D? I tried to, but it caused the character to accelerate exponentially out of control.
Wow, I really like that, I've been looking for this video for a long time
This is amazing. Really hope you keep up with these. Great job!
Finally someone who truly explains how to make proper player movement instead of making something in 20 minutes and showcasing it! Great video, very useful
Thank you!
No thank You for watching :D
Thanks a lot for this tutoriol. I tried so hard to make a good platformer movement and watch a lot of videos. Yours is the best.
I'm from Brazil, and your video is very amazing, I hope it continues.
Very good. ✔
I remembered seeing this video 2 times before, and I remembered it was so simple and informative. And today I am making my first game, and I wanted the controls to feel as good as possible, and then I remembered this video. I searched up something like "Video game movement analysis", and I found it!
Absolute S tier video. I was wondering why my movement felt so stiff and floaty and this improved it by sooo much
Very well explained. Glad I found this
This is the best Player Controller video I’ve seen. Thank you so much!
The quality of the videos. The music and videogame taste. The smooth explaining. There's no reason NOT to be your 500th subscriber! :D
Congratulations, underrated tutorial guy!
And..well..thanks! XD
🥳 Thanks so much! Super happy you enjoyed it, hope it was useful :D
Please keep making these types of videos they’re very useful 🙏🙏🙏
Thank you, this made my platformer feel even better to play!
yo this is a really nice solution; I've always had an issue with figuring out how to get physics-based movement to not feel so sluggish, and the scaling-force-by-difference-from-target-speed thing you have here seems to work pretty well
This video is so high quality, excellent job! Looking forward to more
had an absolute blast watching through this video for 3 days getting everything just right. Great video
Great tutorial! There aren't many others that are targeted for upper beginner / intermediate creators! Keep them coming man!
Thanks a lot! Yeah, i'm loving working on these style videos : D
People don’t realise this video worth infinite. Its so good
Thanks! That means a lot :D
a year late, but howly this is EXACTLY what i need. I want to make a snappy movement but I want it to still able to be affected by AddForce. Thanks a lot dude you just gained a subs!!!!
Very nice video, very educational and also nice, smooth video animation.
The same tutorials on UA-cam are repeated over and over again, using the same methods, and 99% of them are very basic tutorials. Professional and high-quality tutorials like this are rare and must be supported.
This was SO HELPFUL!!!
Thank you and please keep making more tutorials!
This needs to be said right now... This is the best video ever made on youtube, it is so helpfull and so full of information, i would pay money for this information, because im in need of movement system for my 2D Metroidvania
Best video I've seen on game development
Thanks so much!
Damn i finally found what i was looking for. please keep up the good work!!!
Happy it was helpful!
Absolute pure jam, thank you for video!
This is really good! keep going!!!
Thanks a lot :D
Hi, thank you for this video.
Great to find a different way to move than the usual rb.velocity = ...
Also, good to see that you use the new input system.
M. D.
Great video, I'm no game dev but I still feel like I learnt something - and the editing was really great too!
Hey, you look familiar :D
@@DawnosaurDev 👀
Amazing tutorial, You've got yourself a new subscriber! (Also, I just remembered I played you game in the brackeys Game jam, it was super cool)
Thanks so much :D
Great video and of a higher quality than a lot of other Unity tutorials I've seen. Looking forward to your next video
I just started developing and designing games 4 months ago, I'm about to tackle my first platformer in the next few weeks as my next project. This is explained so well and i understood 100% of it!
I'm so proud to be able to look at the code now and understand what it means and I'm so happy to be at a point where if i do end up copying this code, it wont be blindly copy pasting it. I'm still not at the point where i can come up with things like this myself but i can definitely tweak a few things and understand the effect they have and my reasoning for them. Thank you for making this video! i subbed and I'm looking forward to watching many more of your future videos :)
That's so awesome! Really lovely to hear, hope you have a blast making your platformer :D
This is exactly what I needed for the platformer game I'm making, inspired by Celeste and Ori. Earned yourself a sub :D
thanks man. this is awesome. there are so many ways to do this but none of them feel as nice as i would like. I havent tried your way yet but it takes into account a lot of factors that i havent seen considered elsewhere. well done!
Wow bro, really well covered.
Great visualization on why the issue happens! Good video.
fantastic video man!
Thanks so much :D
have had alot of probelms with movement fundamentals, thank you so much for this
this system is FANTASTIC!!
1 question though, wondering if anyone knows.
Instead of flipping the Scale on the X (or changing the "FlipX" on the Sprite Renderer) to get the player to turn around, I generally like to use transform.Rotate(0,180f,0) to get the player to turn around.
That way, the actual transform.right flips, and so any children of the player also turn around properly (and saves you from having to do multiple checks on both the left and right side)
However...implementing this seems to result in a VERY slight (but noticeable) jitter for a frame when the player turns around (only when in the air interestingly) - happens with or without camera follow.
I'm looking for the smoothness you get from flipping the Scale on the X, but the functionality of changing the transform.right. And I don't really want to interpolate the rotation as this produces a Paper-Mario-like effect. Any ideas anyone?
EDIT: solved. This seemed to be a problem when my character was in the air only (gravity using RB, therefore physics simulation) - and since I was checking for this rotation change in update, the physics vs the transform change were fighting each other that frame, resulting in the jittery motion. So the fix, IF you are wanting to change the player's transform.right directly (instead of faking it by using -1 on the x scale) - is to call the CheckForTurn() function in FixedUpdate, not Update.
Awesome, happy to hear you got everything working. Thanks for writing an explainer and the kind words :D
This is explained so clearly, I couldn’t have done it better myself. Thank you! :D
Glad it was helpful :D
I can't believe I missed this tutorial. I used to see this video pop up a lot but always assumed I'd seen it already. God damn it all. I've been squinting at my player's jump. I've gotten it down using velocity instead of add force, but there was always something off about it. Like it didn't feel natural. And the code to control things like gravity, deceleration and acceleration is really messy with velocity compared to that clean force code. Thank you.
Happy it helped!
Man you deserve a lot of love! This video has been extremely helpful. Hope you'll keep making more tutorials and content like these. Awesome work!
Thanks so much, yeah hoping to make a V2.0 at some point :D
Awesome video ! You're teaching so much in such a short amount of time, while still going deep when needed.
Great video. It is easy to make a platformer. But a good player controller is so important for a really good game
HIgh quality for such a small channel
Wow you're insane man. one of the best video I've seen from this subject. Hope you're gonna continue posting some other tuto (yea I know my english is very bad 👀)
This is a very well done tutorial! It covers a lot of ground and gives plenty of code examples for me to replicate. Thank you and keep up the good work!
>:D this was a really good base for 3d first person movement! thank you so much!
Самый полезный канал по разработке, который я только находил, божественно! Хочу больше видеоуроков😍
i always thought i needed to use kinematic and build a whole physics system to be able to make this kind of controller. As i'm making a small project (which is basically a celeste rip-off let's be honest) this video is helping me, and will help me get a better understanding of unity physics system. you are too kind. Thanks man. i mean it.
Good job dude!
Awesome analysis, thanks. 🙂
Very very informative. You've made me want to go back and re-adapt this to my own. Thank you.
Thanks a lot, hope it helps!
Great video! Hope to see your future videos
Great tutorial format! Loved it! :)
The presentation was excellent and I learned a thing or two. Now do one for the oh so important Dashing!
Thanks, definetly in the next one :D
Quickly and well explained :D
i just need to understand it now xD
God damn, what a video. Coding noobs are only able to experience the creative joy of game development because of amazing content like this - thank you!
Thank you so much, I'm currently learning unity and wanted to do a super smooth Gameplay, but I only got close, now I can finally implement this :D
Please keep making great videos like this one! They are well-edited, concise, and pack a lot of useful information in a short amount of time! Also, you explain things incredibly well!
Thanks so much!
Wow. This video is very well made and informative. Congrats dude! For some feedback, I would suggest adding some diagrams when explaining the coding parts to break up some of the visual monotony. The video flows super well, while keeping a steady pace. Subbed, fantastic job!
Thanks so much! Yeah, diagrams are a great idea. I'll definitely be putting that on the to-do list for any sequels i make :D
thank you so much for creating this video it has influenced me to get into coding
Hey! fancy seeing you here ;D
This is so awesome! I've been looking for a way to create a 2D platform character controller that works with Physics for a long time but just couldn't seem to find any good tutorials or examples online. I downloaded your project and was so happy at how clean and tidy the code and the scene are! Thank you so much for the amount of work you put into this!
Have you thought about creating a step-by-step tutorial on how you created the code for the playerMovementImproved script?
Thanks so much! I probably won't make a step by step tutorial, but if you have any questions about the code, feel free to ask me anything here :D
@@DawnosaurDev Thank you!
thank you very much for such a masterpiece of a video!!!! only 7 mins, but much more informative and useful than longer ones.
🔥🔥🔥🔥
Thanks so much!
Happy it helped :D
Just realized that I never left a comment on here, anyways, this video is amazing! Everything is explained very well and the visuals really helped to explain the code. Thank you.
Thanks so much! Happy it helped you out
Really informative and usefull. Easily earned subscribe. Good job.
Oh god, this video is really good and helpful. Hope you can keep doing this series.
Very Awesome video Mate!
Straight to the point with Amazing tips!
UA-cam needs more tutorials like this. Keep it up!
Thanks that means a lot :D
Thank you for making this! I’m making a 3D platformer and want the controls to be somewhere between Hat in Time and Blue Fire.
I finally caved and decided to just use your movement tutorial, I tried for at least 8 to get and use my own movement system through the power of knowing a highschool amount of math and physics, this one works so much better lmao, at least I tried, good work with yours and thanks
bro has changed the industry without noticing
Great tutorial! That's a really clean platformer controller you've made. Can't wait to see what you do next ;)
Thanks so much! Hopefully i'll finishing up my next video soon :D
great video, really helped me out w/ my project for school!
That's awesome! What's your school project on if you don't mind me asking?
@@DawnosaurDev We are making a 2d platformer in unity for our final project in my game design class, and my game really benefited from less floaty controls
@@georgemcgurkin7846 Neat! Hope it goes great
This video is completely insane, just continue what u doing it's amazing :D Gj mate
Thanks a lot :D
GREAT content man! Will sub for sure :)
thank you so much. That will help my game much less boring
Thanks!
This helps a lot
This is really helpfull! You explain this really well and its really easy to follow
You're amazing!! Thank you for this, definitely subscribed ^^
Well done man, super informative
Thanks! Happy it helped
This was great, really helps me a lot this is exactly what i needed. Thank You and keep it up :)
Thanks. The exact kinds of tips I was looking for!