Hey! This is a cool controller - got it feeling nice. Wondered if you had any advice on handling moving platforms? The frictionless physics material makes it so the character doesn't move with a moving Rigibody (I've tested using DOTween on a Rigidbody2D and the character doesn't move with it). Any ideas would be great!
Hi, nice to see you here! My solution would be to keep track of the connected body the one that is in direct contact with the sphere. You can do that by retrieving the object's Rigidbody2D the sphere is in contact with. Next to determine the motion just subtract the position the connected object is currently at with its previous one, that will give you the connected object's movement that needs to be divided by the deltaTime to get the actual speed. Once you have the speed of the connected object just subtract that to the velocity of the sphere to have the relative velocity. I skipped a lot of steps because i just wanted to give you an idea on how to solve this issue, hope this will help you!
@@GMTK If you don't seem to find a proper way to implement it or the solution i described has some flaw, i can provide another tutorial that covers it, sometime next week if you are not in a hurry...
Exactly my problem since I tried rigidbody player movement, it seems almost impossible to solve moving problem so I guess I will rewrite my character controller to use transform.translate and use raycasts etc. this way it’s easy to implement moving platforms. …. I wasted over a week with rigidbodies and couldn’t find a solution. There are tons of problems to figure out that you don’t think at first, what if you block the moving platform from moving with the player? What if you stand on the edge of the platform and the platform goes next to a wall to prevent glitching through the wall?
I truly admire the cleanliness of how this code is laid out and how so many components are built to be used by a variety of entities. Well done, and thank you!
This is the longest video I've done so far, what a challenge! But i wanted to share this video with all of you, because this is one of the pillars of 2D Games, Character Movement may sometimes be overlooked or given for granted, but it is an essential part of the game. So with this tutorial i wanted to give you some tips on how to create a scalable and multi purpose controller not only for the Player but for all the characters in your game!
Thank you for this quality tutorial with clean and reusable code. I just started exploring gamedev (I have background in web/apps). There is plenty of tutorials about Unity and C#, but rarely someone spends time organizing code and making it resuable. Thats one of basic truths of programming: "less code is always more".
I like how you explained the reasoning behind how you did certain things. A lot of videos just say to 'do this' without any further explanation, and it leaves me little idea on how I can further expand on a mechanic. Keep up the good work!
Mate it is an absolute disgrace that this only has 3000 views. Phenomenal quality content, and belongs alongside brackeys etc. Clear, concise and actually useful, unlike the majority of nonsense in the pages and pages of content I had to shift through to find this gem.
@@slipperynickels completely deserved shout out, this is one of the strongest skeleton controllers out there imo. Good luck with whatever you're working on in godot :)
Now this is a master platform movement controller. Adjust here and there for your own prefs and it is just amazing, made my game more interactive and fun.
Amazing. I‘ve seen dozens of such videos, but this is looks like the best. Very good care for more advanced, but important things. I recommend to begin, and tease with a few seconds showing off the result, so viewers get enticed. And after that, give a brief overview of which parts or scripts are being made and why. Excellent work, thank you!
I totally agree on showing how the different scripts work together in a kind of diagram expecially on wide systems like this one. The only reason i didn't show the ending result at the beginning is that i felt that showing a cube moving wasn't that interesting... But I'll try to make up for that next time, thank you for your kind words!
Intresting controller setup with good architectural structure. I ve seen a lot of ways this can be done but this is quite unique setup. I m gonna give it a try. Edit: Man this works very well as it is very easy to configure the movement. I am so glad i watched this trough as i had already created another controller for my prototype. I managed to convert this into 3D as i am working on a 2.5D style game and i m now into the proccess of adding Jump Buffer, Coyote Time and Jump Corner Correction so i dont get stuck under platforms when jumping, but this was an amazing base for the controller and beleive me i ve watched / read a lot of ways to do things. The structure and configurability of this is awesome! Thank you very much for this and keep up the good work!
So why exactly did you make the InputController a scriptableObject (instead of like a static class or none at all) ? Does not make much sense in a vacume
I came here from GMTK because he praised your character controller and I have to agree, I like it very much. I was hoping, as someone who wants to do well in this professionally someday, what process brought you to being able to design this? How did you get as good as you have at developing character movement?
First i want to thank you for your kind words, this is a dear question to me since i remember asking the same thing to a RUclipsr around 2017, so having it asked back at me feels quite strange and i feel a responsibility in answering as best as i can. Of course i didn't become accustomed to Unity's workflow by the night, it did require 1.5/2 years of developing games almost every day, since that was what i wanted to do i focused 100% on that, and after watching and reading a lot of material about Unity, i just didn't require to lookup things up anymore. But even after that, i still didn't know how to properly organize the work, design systems that were scalable and did work well together. So i started focusing my attention on actual game design videos, books, and any other type of resource. Luckily I'm a fan of well written code so this was one of my favorite parts, but for other people it may be boring to the point where you neglect doing this part properly. And i want to specify that this is the MOST IMPORTANT part in programming, especially if you are interested in pursuing this career. A lot of the things that you will learn from a design perspective can be used even in other fields so i can't stress enough the importance of designing good systems before hand, i usually use Flowcharts to do so and it helps me quite a lot in visualizing how things work and interact with one another. Lastly, as bad as it could sound this is the one that carries out pretty much any field in any industry, to steal from others and improve upon that. Remember I'm saying stealing not copying, as Pablo Picasso said “Bad artists copy, great artists steal”. This will help you have a good reference for a starting point and then you can study ways to improve them or to change them so that they suit your needs. This overtime will improve your overall understanding of code, if you can do the same even when following tutorials or any kind of material on the subject, try giving it your own twist so that you don't just copy it. A way of doing this is to decide to make a small project, very small and with zero knowledge on the subject step by step look what you actually need for that project to be done. This will make so that you will encounter problems that you will have to solve in your own way. To summarize things up: -(Learn) Get used to the technology that you want to use, whatever it is, it will be the most time consuming part. -(Design) After you are accustomed to it, improve how you make things, now you have the knowledge so you can refine things up. -(Steal) To have a good starting point for your projects, look at those who have succeeded and improve upon their work. Bonus Point: PERSEVERE if this is the career that you want to pursue, give it your all! If you want to know more, about which resources i did use or i suggest following, please consider joining my Discord, is free, quiet and discrete, I don't write very often but i do answer questions every time.
@@Shinjingi Thank you very much for the reply, I really did learn a lot from your code. Your method of ground checking was a great use of one of the design patterns (name escapes me) and it was very instructive in using multiple scripts instead of having one bloated script. With that said, I may see how to make your input controller work with addforce instead of velocity!
Having the same question for you and since you already answered it, I have to tank you for taking your time to write such a great response, since it not only attended the person that made the question but all of us newbies exited to learn game dev having the same doubts! I don’t know if your Discord still on but I’ll try to join right away! Cheers and thanks for the excellent content!
i tryed it and get a lot of errors but even if i can fix some i still get this one (NullReferenceException: Object reference not set to an instance of an object ground.retrivefiction (UnityEngine.Collision2D collision) (at Assets) or thr player keep floating
That is because you don't have a rigidbody2D component attached to the ground onject. Add a rigidbosy component to the ground, set it to static and give it a physics material (I just saw the comment was 4 months old 😶)
I followed the instructions perfectly, but when it comes time to add the move script to the character, it doesn't let me because "the script class cannot be found." It also has given me an error stating that the Ground script "cannot implicitly convert type 'UnityEngine.Rigidbody2D' to 'UnityEngine.PhysicsMaterial2D' and I have no idea how to fix it
Good job, awesome script. You should do a video where you attach the player sprites to the scripts you just made, that would be a great help for a lot of people. Thanks
Another great idea would be to add some other scripts like slide, various attacks or skills, wallslide. Because you are great at making this scripts and I found 0 scripts on youtube that are clear like yours. Great job again
Gotta say, I keep coming back to this video. This deserves way more attention than it's getting. Excellent work! The one thing I noticed is that tweaking the upwardMovementMultiplier variable changes the height of the player's jump. It looks like your jumpHeight calculation doesn't consider that upward multiplier. To fix: float jumpSpeed = Mathf.Sqrt(-2f * Physics2D.gravity.y * jumpHeight); ...should become... float jumpSpeed = Mathf.Sqrt(-2f * Physics2D.gravity.y * jumpHeight * upwardMovementMultiplier); This change allows you to tweak the upwardMovementMultiplier without affecting jump height, and ensures that your character will jump the specified height in meters every time.
Really great tutorial. A game I'm working on actually uses similar methods and due to this I wanted to ask if you found any good way to add slope handling? Most of the tutorials are designed around setting a velocity unlike this method which uses acceleration. Any information would be really helpful. Thank you.
Hello! This is an amazing platformer controller, and I really love the method you used to get the movement to feel fluid and the jumping to feel firm and satisfying! I used this tutorial in making my project, and I came across an issue, and I was wondering if you or anyone else in the comments could help. When I try to double jump, if i do it immediately after the first jump, it is a good height, but if I start to fall down a little before jumping again, the jump barely makes the player go up. I am assuming that this is because of the downward force that is applied to the player at the fall of the jump, but i do not know how to fix it. Thank you!
Hello there, I’m not sure of you’ve already found a solution to this, but I wanted to explain mine. I removed the if(desiredJump) statement made at 13:20 and copied it into each of the if(body.velocity.y) statements made at 13:29, 13:38 and 13:43. However for the if(body.velocity.y < 0) I added velocity.y = 0 in the if(desiredJump) copied earlier. If anyone found a better solution please let me know.
Just wanted to add my own solution for others. I made velocity.y = jumpSpeed at the end of JumpAction(), rather than using +=. Then remove the if(velocity.y > 0f) statement before it, because we don't care what our vertical velocity was if we want the jump to act the same way each time
You're an amazing guide with a useful script structure that I would like to take guidance from for my first game. However, I'm brand new to game dev, working on a solo project in my free time, coming from an art background. I followed your guide but can't seem to figure out how to implement animating my sprites with this player controller. I've tried several things including making an animation manager script but I'm such a beginner I can't wrap my head around everything involved. Any advice on how to move forward with my animations?
Hi, if you are just starting out i would recommend to follow CodeMonkey 10 hours long video, it will get you started in the right way. This series is meant to give a different approach on how to develop a character controller that works both for the player and the enemies.
Hey great controller, can you make a tutorial to add jump buffer and hold jump button to jump higher because I have some problems when I try to make them, and thank you for your tutorial❤️
This was a really good video, it really helped me with what I wanted to do, and I hope you will continue doing tutorials for other Capabilities(like attacking and shooting etc.) !
I was doing great for most of the video but this |= operator is confusing me. Can anyone point me toward some information on how I can understand how this is being used? From what I saw online it looked like a bitwise or assignment operation that I know from javascript - is this correct? Amazing video by the way I am so excited to work through this 2D controller series!!
Hello! Thank you for this great video, I am trying to follow along and have hit a snag. I noticed that in the jump script there is a new line called "private Controller controller;" but unity tells me that Controller is not valid. I am trying to see between this video and the improved jump video where this controller gets implemented and what it could be, is it called something else now?
I'm noticing a problem with the screen resolutions. if i set the jump to 100. and the resolution is at 1920x1080.... its barel ya hop. but if i set the screen resolution to 1280x720 the character is simply launched out of the screen. i think this has to do with how units and pixels are determined. any ideas?
Amazing tutorial. I’m just doubting the ground check part because it doesnt work on slopes and i was wandering if it wouldnt be easier to check if the game object had a certain tag or layer? If theres a better solution could you make a tutorial on that?
To both, the answer is yes. I'm going to release another video in 2 weeks which covers converting the controller to the new input system. After that i will cover the ground issue.
Nothing here is working on my visual studio or unity, first 4 minutes in and its not letting me implement abstract class, 1 minute later, I cant find any of the assets that I supposedly created. and I have tried everything but it hasnt worked. I've even deleted and reinstalled unity and visual studio but nothing has worked. nothing I've found online has helped. and I have yet to find a video where it explains how to import a player controller from other files. i really need help here.
I love this tutorial and the concept of it but I am stuck. In visual studio I have an error (red squiggly line) under return if; in the AIController. I also have issues at timestamp 9:48 when you are adding move and ground scripts to the character. I get the error message can't add script component 'Move' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match. I get a duplicate message like this for the ground script. The only compile error I am finding is in the AIController as mentioned above. Any idea what I am doing wrong?
for some reason i cant use the implement abstract class, Im guessing that something went wrong because my screen didn't have the squiggly line under player controller 4:06
Supposing your sprites are all oriented to the right, set the local scale X to 1 when going right and -1 when going left, this will flip your sprites in the direction you are facing
Love the content, and maybe this is too advanced of a character controller for me, but how would you control character animations through this system? Is it better to completely leave it alone and use triggers or bools rather than the horizontal float method?
If the project i work on is in 2D then I just use a state machine that actually plays the animation the state is in (Idle, Walking, Jumping...) This makes sure that both the action in the code and the one in the animator act at the same time. If the project is in 3D and i need all the blending features that the animator offers, I do a similar thing but instead of playing the animation directly, I do that by setting parameters and the conditions will take care of playing the appropriate animation.
@@Shinjingi ok rad, makes sense. How well so would this handle slopes? I’m using a basic rigidbody2d.addforce for movement but when I reach the top of stairs, the momentum continues forward and it flies off.
This is an amazing character controller! One question though, depending on when i press jump the character will have a bigger or smaller second jump. is there a way to make it so its always the same jump?
It should be solved in later videos of the series, basically what is happening is the following: If you are going down let's say at a speed of -3f and the jumpSpeed it's 6f the currentSpeed+jumpSpeed=3f instead of the 6f it should be. So to solve this issue you need to make sure that even when going down you set the speed of the jump to the proper value. This can be achieved in different ways, I'll leave that part to you
Thank you for this amazing controller. I had my own but this is much more advanced than mine. One thing is bothering me though. I cannot resolve an issue when I am close to a vertical wall in tilemap and I want to jump. It thinks that I am touching ground even after the first jump. This is happening only for tilemap and for box collider it works well. On tilemap I am using tilemap collider together with composite collider. Any advice on that? Thanks in advance
Thanks for the nice video,. help me a lot understanding more and smart ways to setup. i just have 1 problem. the player doesn't seem to get in touch with the ground. i can jump the max air jump and that is it. but if i touch the sides and the bottom of the ground, the jumps gets reset. and still if i rotate the ground or the player. is still happens the same way.. any ide ?
Thank you Glenn. If you have a problem with the collision detection it has to be something with the Box or Edge collider bot being properly set up. You can check it in the appropriate script in the OnCollisionEnter2D() and OnCollisionStay2D() methods. If you don' t seem to find a solution for it, i suggest to download the project available on Github, link in the description.
This looks really good! I did have a quick question though. In the move script, you use Time.deltaTime for calculating maxSpeedChange, but this calculation is done in fixedUpdate. Shouldn't you use Time.fixedDeltaTime instead to avoid issues with frame rate dependency?
I'm probably the biggest Noob in here and It's making me feel disheartened as I'd love to make my own game :( Not even a minute in and I'm stuck. I created a material, called it "Trail" then I go to change the colour and for me there is no colour option whatsoever. Apparently it works differently if I am using URP but how is the question. How am I the only one in these comments that cant get past the first minute without getting stuck. Grrr...
Hey! This is a cool controller - got it feeling nice. Wondered if you had any advice on handling moving platforms? The frictionless physics material makes it so the character doesn't move with a moving Rigibody (I've tested using DOTween on a Rigidbody2D and the character doesn't move with it). Any ideas would be great!
Hi, nice to see you here! My solution would be to keep track of the connected body the one that is in direct contact with the sphere. You can do that by retrieving the object's Rigidbody2D the sphere is in contact with. Next to determine the motion just subtract the position the connected object is currently at with its previous one, that will give you the connected object's movement that needs to be divided by the deltaTime to get the actual speed. Once you have the speed of the connected object just subtract that to the velocity of the sphere to have the relative velocity. I skipped a lot of steps because i just wanted to give you an idea on how to solve this issue, hope this will help you!
@@Shinjingi Thanks for the reply! I will… try and implement this!
@@GMTK If you don't seem to find a proper way to implement it or the solution i described has some flaw, i can provide another tutorial that covers it, sometime next week if you are not in a hurry...
@@Shinjingi That’d be awesome - I’m a bit out of my depth with this! You will, of course, get full credit in the game and videos :)
Exactly my problem since I tried rigidbody player movement, it seems almost impossible to solve moving problem so I guess I will rewrite my character controller to use transform.translate and use raycasts etc. this way it’s easy to implement moving platforms. …. I wasted over a week with rigidbodies and couldn’t find a solution. There are tons of problems to figure out that you don’t think at first, what if you block the moving platform from moving with the player? What if you stand on the edge of the platform and the platform goes next to a wall to prevent glitching through the wall?
I truly admire the cleanliness of how this code is laid out and how so many components are built to be used by a variety of entities. Well done, and thank you!
This is the longest video I've done so far, what a challenge! But i wanted to share this video with all of you, because this is one of the pillars of 2D Games, Character Movement may sometimes be overlooked or given for granted, but it is an essential part of the game. So with this tutorial i wanted to give you some tips on how to create a scalable and multi purpose controller not only for the Player but for all the characters in your game!
Thank you for this quality tutorial with clean and reusable code. I just started exploring gamedev (I have background in web/apps). There is plenty of tutorials about Unity and C#, but rarely someone spends time organizing code and making it resuable. Thats one of basic truths of programming: "less code is always more".
I like how you explained the reasoning behind how you did certain things. A lot of videos just say to 'do this' without any further explanation, and it leaves me little idea on how I can further expand on a mechanic. Keep up the good work!
Thank you i appreciate it!
Mate it is an absolute disgrace that this only has 3000 views. Phenomenal quality content, and belongs alongside brackeys etc. Clear, concise and actually useful, unlike the majority of nonsense in the pages and pages of content I had to shift through to find this gem.
it's about to get more after getting namedropped and linked in today's gmtk video. i'm here from there and am about to port this controller to godot.
@@slipperynickels completely deserved shout out, this is one of the strongest skeleton controllers out there imo. Good luck with whatever you're working on in godot :)
Now this is a master platform movement controller. Adjust here and there for your own prefs and it is just amazing, made my game more interactive and fun.
Amazing. I‘ve seen dozens of such videos, but this is looks like the best. Very good care for more advanced, but important things. I recommend to begin, and tease with a few seconds showing off the result, so viewers get enticed. And after that, give a brief overview of which parts or scripts are being made and why. Excellent work, thank you!
I totally agree on showing how the different scripts work together in a kind of diagram expecially on wide systems like this one. The only reason i didn't show the ending result at the beginning is that i felt that showing a cube moving wasn't that interesting... But I'll try to make up for that next time, thank you for your kind words!
Intresting controller setup with good architectural structure. I ve seen a lot of ways this can be done but this is quite unique setup. I m gonna give it a try.
Edit: Man this works very well as it is very easy to configure the movement. I am so glad i watched this trough as i had already created another controller for my prototype. I managed to convert this into 3D as i am working on a 2.5D style game and i m now into the proccess of adding Jump Buffer, Coyote Time and Jump Corner Correction so i dont get stuck under platforms when jumping, but this was an amazing base for the controller and beleive me i ve watched / read a lot of ways to do things. The structure and configurability of this is awesome! Thank you very much for this and keep up the good work!
Thank you, wish you the best with your project!
So why exactly did you make the InputController a scriptableObject (instead of like a static class or none at all) ? Does not make much sense in a vacume
I've got the error "The type or namespace name 'Controller' could not be found", any way to fix this or is this because of the new input system?
I came here from GMTK because he praised your character controller and I have to agree, I like it very much. I was hoping, as someone who wants to do well in this professionally someday, what process brought you to being able to design this? How did you get as good as you have at developing character movement?
First i want to thank you for your kind words, this is a dear question to me since i remember asking the same thing to a RUclipsr around 2017, so having it asked back at me feels quite strange and i feel a responsibility in answering as best as i can.
Of course i didn't become accustomed to Unity's workflow by the night, it did require 1.5/2 years of developing games almost every day, since that was what i wanted to do i focused 100% on that, and after watching and reading a lot of material about Unity, i just didn't require to lookup things up anymore.
But even after that, i still didn't know how to properly organize the work, design systems that were scalable and did work well together. So i started focusing my attention on actual game design videos, books, and any other type of resource. Luckily I'm a fan of well written code so this was one of my favorite parts, but for other people it may be boring to the point where you neglect doing this part properly. And i want to specify that this is the MOST IMPORTANT part in programming, especially if you are interested in pursuing this career. A lot of the things that you will learn from a design perspective can be used even in other fields so i can't stress enough the importance of designing good systems before hand, i usually use Flowcharts to do so and it helps me quite a lot in visualizing how things work and interact with one another.
Lastly, as bad as it could sound this is the one that carries out pretty much any field in any industry, to steal from others and improve upon that. Remember I'm saying stealing not copying, as Pablo Picasso said “Bad artists copy, great artists steal”. This will help you have a good reference for a starting point and then you can study ways to improve them or to change them so that they suit your needs. This overtime will improve your overall understanding of code, if you can do the same even when following tutorials or any kind of material on the subject, try giving it your own twist so that you don't just copy it. A way of doing this is to decide to make a small project, very small and with zero knowledge on the subject step by step look what you actually need for that project to be done. This will make so that you will encounter problems that you will have to solve in your own way.
To summarize things up:
-(Learn) Get used to the technology that you want to use, whatever it is, it will be the most time consuming part.
-(Design) After you are accustomed to it, improve how you make things, now you have the knowledge so you can refine things up.
-(Steal) To have a good starting point for your projects, look at those who have succeeded and improve upon their work.
Bonus Point: PERSEVERE if this is the career that you want to pursue, give it your all!
If you want to know more, about which resources i did use or i suggest following, please consider joining my Discord, is free, quiet and discrete, I don't write very often but i do answer questions every time.
@@Shinjingi Thank you very much for the reply, I really did learn a lot from your code. Your method of ground checking was a great use of one of the design patterns (name escapes me) and it was very instructive in using multiple scripts instead of having one bloated script. With that said, I may see how to make your input controller work with addforce instead of velocity!
Having the same question for you and since you already answered it, I have to tank you for taking your time to write such a great response, since it not only attended the person that made the question but all of us newbies exited to learn game dev having the same doubts! I don’t know if your Discord still on but I’ll try to join right away! Cheers and thanks for the excellent content!
This is the only one that actually worked it was worth the headache xD
Super Impressive but I am waaaaaay too slow to keep up with that speed of your typing and shortcut use.
i tryed it and get a lot of errors but even if i can fix some i still get this one (NullReferenceException: Object reference not set to an instance of an object
ground.retrivefiction (UnityEngine.Collision2D collision) (at Assets)
or thr player keep floating
That is because you don't have a rigidbody2D component attached to the ground onject.
Add a rigidbosy component to the ground, set it to static and give it a physics material
(I just saw the comment was 4 months old 😶)
@@meshhra Well, I was having the same problem so very glad you commented this 😁
I followed the instructions perfectly, but when it comes time to add the move script to the character, it doesn't let me because "the script class cannot be found."
It also has given me an error stating that the Ground script "cannot implicitly convert type 'UnityEngine.Rigidbody2D' to 'UnityEngine.PhysicsMaterial2D' and I have no idea how to fix it
It means you have a typo. You can fix this by making both this line in your move Script:
public class *this one **->-*- Ground -*-
Good job, awesome script. You should do a video where you attach the player sprites to the scripts you just made, that would be a great help for a lot of people. Thanks
Another great idea would be to add some other scripts like slide, various attacks or skills, wallslide. Because you are great at making this scripts and I found 0 scripts on youtube that are clear like yours. Great job again
Hey! It's a nice controller and a well explained video, what more? You got a new sub. Thanks! It's the controller I was looking for.
Gotta say, I keep coming back to this video. This deserves way more attention than it's getting. Excellent work!
The one thing I noticed is that tweaking the upwardMovementMultiplier variable changes the height of the player's jump. It looks like your jumpHeight calculation doesn't consider that upward multiplier.
To fix:
float jumpSpeed = Mathf.Sqrt(-2f * Physics2D.gravity.y * jumpHeight);
...should become...
float jumpSpeed = Mathf.Sqrt(-2f * Physics2D.gravity.y * jumpHeight * upwardMovementMultiplier);
This change allows you to tweak the upwardMovementMultiplier without affecting jump height, and ensures that your character will jump the specified height in meters every time.
Splendind suggestion! Thanks for your words, a new video is coming soon. I'll try to remember to put this fix on it!
Really great tutorial. A game I'm working on actually uses similar methods and due to this I wanted to ask if you found any good way to add slope handling? Most of the tutorials are designed around setting a velocity unlike this method which uses acceleration. Any information would be really helpful. Thank you.
Hello! This is an amazing platformer controller, and I really love the method you used to get the movement to feel fluid and the jumping to feel firm and satisfying! I used this tutorial in making my project, and I came across an issue, and I was wondering if you or anyone else in the comments could help. When I try to double jump, if i do it immediately after the first jump, it is a good height, but if I start to fall down a little before jumping again, the jump barely makes the player go up. I am assuming that this is because of the downward force that is applied to the player at the fall of the jump, but i do not know how to fix it. Thank you!
Hello there, I’m not sure of you’ve already found a solution to this, but I wanted to explain mine. I removed the if(desiredJump) statement made at 13:20 and copied it into each of the if(body.velocity.y) statements made at 13:29, 13:38 and 13:43. However for the if(body.velocity.y < 0) I added velocity.y = 0 in the if(desiredJump) copied earlier. If anyone found a better solution please let me know.
@@kingblob3386 Just type if(body.velocity.y < 0) velocity.y = 0; into the if(desiredJump) statement before JumpAction();
Just wanted to add my own solution for others. I made velocity.y = jumpSpeed at the end of JumpAction(), rather than using +=. Then remove the if(velocity.y > 0f) statement before it, because we don't care what our vertical velocity was if we want the jump to act the same way each time
@@cosmickly Great solution, thanks!
Nice video, but my AIController isnt appearing when try to create it through input controller for the ScriptibleObjects folder, any help? 5:20
You're an amazing guide with a useful script structure that I would like to take guidance from for my first game. However, I'm brand new to game dev, working on a solo project in my free time, coming from an art background. I followed your guide but can't seem to figure out how to implement animating my sprites with this player controller. I've tried several things including making an animation manager script but I'm such a beginner I can't wrap my head around everything involved. Any advice on how to move forward with my animations?
Hi, if you are just starting out i would recommend to follow CodeMonkey 10 hours long video, it will get you started in the right way. This series is meant to give a different approach on how to develop a character controller that works both for the player and the enemies.
Hey great controller, can you make a tutorial to add jump buffer and hold jump button to jump higher because I have some problems when I try to make them, and thank you for your tutorial❤️
I'll do another video that adds more functionalities to it, it will require some time but you can expect one in the near future.
@@Shinjingi Thank you very much ❤️, I will wait for it
This was a really good video, it really helped me with what I wanted to do, and I hope you will continue doing tutorials for other Capabilities(like attacking and shooting etc.) !
2 questions how can i make variable jump height, and how can i make it no acceleration or anything like that
Good video! I just wonder if it's possible to deal with slopes given this approach.
The best 2d Character CONTROLLER for UNITY, thank you !!!!!
I was doing great for most of the video but this |= operator is confusing me. Can anyone point me toward some information on how I can understand how this is being used? From what I saw online it looked like a bitwise or assignment operation that I know from javascript - is this correct? Amazing video by the way I am so excited to work through this 2D controller series!!
Thank you! Someone already asked this question in the comments below. You can check that!
Hello! Thank you for this great video, I am trying to follow along and have hit a snag. I noticed that in the jump script there is a new line called "private Controller controller;" but unity tells me that Controller is not valid. I am trying to see between this video and the improved jump video where this controller gets implemented and what it could be, is it called something else now?
for some reason, it detects it as grounded when i touch a wall
Hi. I want to make a game in which I want that enemy jump toward me when my Player reaches a specific point. Please help me
Will you make more Tutorials in the future? Because you make great content!
Thank you! Yes, I'm just waiting for the right time since I recently got a new job.
i have followed step by step and have no errors in any of the codes but i cant move my character
Hi, any sugestion for make this controller work for movile 2d joystick ?, Great video
I'm noticing a problem with the screen resolutions.
if i set the jump to 100. and the resolution is at 1920x1080.... its barel ya hop.
but if i set the screen resolution to 1280x720 the character is simply launched out of the screen.
i think this has to do with how units and pixels are determined.
any ideas?
What is the theme you are using in Visuasl Studio in this video? It's really good.
Just the Dark one, no changes done.
@@Shinjingi "public class" and "void Start" are pink. But they are not in normal Dark theme. It looks beutiful. But if you don't know It's okay :)
Does anyone know why I didn't get the red squiggly line and the implement option like in 4:08?
Amazing tutorial. I’m just doubting the ground check part because it doesnt work on slopes and i was wandering if it wouldnt be easier to check if the game object had a certain tag or layer? If theres a better solution could you make a tutorial on that?
To both, the answer is yes. I'm going to release another video in 2 weeks which covers converting the controller to the new input system. After that i will cover the ground issue.
@@Shinjingi thank you!
hi im running into problems with the Move Script its saying that the name Controller couldnt be found. any ideas thanks in advance
Hi, i suggest to download the project from Github and have a look at what's different on your project, this is the fastest way to solve your issue.
Nothing here is working on my visual studio or unity, first 4 minutes in and its not letting me implement abstract class, 1 minute later, I cant find any of the assets that I supposedly created.
and I have tried everything but it hasnt worked. I've even deleted and reinstalled unity and visual studio but nothing has worked. nothing I've found online has helped. and I have yet to find a video where it explains how to import a player controller from other files. i really need help here.
Download the project from GitHub, link in the description
for some reason the my player is not jumping. Can anyone help me find what is wrong about this?
Would it be possible to use this for commercial purposes without credits?
Yes
Damn I wish this was less complicated. All this abstract asset menu input controller I don't know what any of that is
I love this tutorial and the concept of it but I am stuck. In visual studio I have an error (red squiggly line) under return if; in the AIController. I also have issues at timestamp 9:48 when you are adding move and ground scripts to the character. I get the error message can't add script component 'Move' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match. I get a duplicate message like this for the ground script. The only compile error I am finding is in the AIController as mentioned above. Any idea what I am doing wrong?
Download the full project in the description, the one for this episode and compare the code with yours. That's the best way to get rid of errors
@@Shinjingi Thank you! I found the error. I had a typo. You had 1f for the return value not if. My bad.
for some reason i cant use the implement abstract class, Im guessing that something went wrong because my screen didn't have the squiggly line under player controller 4:06
did you find a solution?
How could I make this code flip on the x axis when turning and have animation when moving
Supposing your sprites are all oriented to the right, set the local scale X to 1 when going right and -1 when going left, this will flip your sprites in the direction you are facing
@@Shinjingi but how would I change a variable when going specifically to the left
at 5:07, the "input controller" selection on your menu doesn't show up for me
check if the names are right. happens to me a lot
it work in any unity editor
Has anyone figured out how to implement this using the new Input System?
thats what Im tring to figure out. I dont think hes responding to comments anymore :(
@@Ddotkay Well, our prayers have been answered. He released a video on the new input system 2 months ago! 😅
Love the content, and maybe this is too advanced of a character controller for me, but how would you control character animations through this system? Is it better to completely leave it alone and use triggers or bools rather than the horizontal float method?
If the project i work on is in 2D then I just use a state machine that actually plays the animation the state is in (Idle, Walking, Jumping...) This makes sure that both the action in the code and the one in the animator act at the same time. If the project is in 3D and i need all the blending features that the animator offers, I do a similar thing but instead of playing the animation directly, I do that by setting parameters and the conditions will take care of playing the appropriate animation.
@@Shinjingi ok rad, makes sense. How well so would this handle slopes? I’m using a basic rigidbody2d.addforce for movement but when I reach the top of stairs, the momentum continues forward and it flies off.
awesome!
Did everything exactly the same but jumping doesn't work. My character just floats to the ground. Need help
check the input jump in the project settings, maybe that's it
This is an amazing character controller! One question though, depending on when i press jump the character will have a bigger or smaller second jump. is there a way to make it so its always the same jump?
It should be solved in later videos of the series, basically what is happening is the following: If you are going down let's say at a speed of -3f and the jumpSpeed it's 6f the currentSpeed+jumpSpeed=3f instead of the 6f it should be. So to solve this issue you need to make sure that even when going down you set the speed of the jump to the proper value. This can be achieved in different ways, I'll leave that part to you
@@Shinjingi Oh i didnt know this was a video series. Thank you for the help!
@@irishmalteser296 It's only a series if you want to, if not take what you need and improve on it, good luck!
@@Shinjingi Will do. Thank you for the help!
Im unable to jump I dono why I completely followed the tutraial
i loved this video
Thank you for this amazing controller. I had my own but this is much more advanced than mine. One thing is bothering me though. I cannot resolve an issue when I am close to a vertical wall in tilemap and I want to jump. It thinks that I am touching ground even after the first jump. This is happening only for tilemap and for box collider it works well. On tilemap I am using tilemap collider together with composite collider. Any advice on that? Thanks in advance
Did you find any solution?
Thanks for the nice video,. help me a lot understanding more and smart ways to setup. i just have 1 problem. the player doesn't seem to get in touch with the ground. i can jump the max air jump and that is it. but if i touch the sides and the bottom of the ground, the jumps gets reset. and still if i rotate the ground or the player. is still happens the same way.. any ide ?
Thank you Glenn. If you have a problem with the collision detection it has to be something with the Box or Edge collider bot being properly set up. You can check it in the appropriate script in the OnCollisionEnter2D() and OnCollisionStay2D() methods. If you don' t seem to find a solution for it, i suggest to download the project available on Github, link in the description.
This looks really good! I did have a quick question though. In the move script, you use Time.deltaTime for calculating maxSpeedChange, but this calculation is done in fixedUpdate. Shouldn't you use Time.fixedDeltaTime instead to avoid issues with frame rate dependency?
Time.deltaTime gets automatically converted to fixedDeltaTime when used in FixedUpdate.
@@Shinjingi Interesting, I didn't know that! Thanks!
Does this still work with the 2022 editors?
I don't know I'm still using the latest LTS
Unity is so good
would this work for a 2.5d game
If you mean something like Octopath Traveler the answer is no.
@@Shinjingi I meant something like donkey kong country tropical freeze.
@@xxfantomxx6 Yes that would work, the game is constrained in 2 axis (X,Y). So doesn't matter if models are 3D.
@@Shinjingi thank you
hmm just couldn't get the jump to feel smooth :/
Read whutsurnaymPersonal comment below, it's a required change I will discuss in the upcoming video
I'm probably the biggest Noob in here and It's making me feel disheartened as I'd love to make my own game :(
Not even a minute in and I'm stuck. I created a material, called it "Trail" then I go to change the colour and for me there is no colour option whatsoever. Apparently it works differently if I am using URP but how is the question. How am I the only one in these comments that cant get past the first minute without getting stuck. Grrr...
i didn't understand shit. I'm just tryna move left and right
Ultimate 2d controller? its like 50 lines? also, physics materials?? yuck, good luck making good controls with that setup
heya! it's been three months, did you manage to make something out of your way better setup? can i see?
9:15 - shouldn't this be `Time.fixedDeltaTime`?
Time.DeltaTime gets automatically converted to FixedDeltaTime inside FixedUpdate()