Usually I like your tutorials, but this one isn't great. It doesn't really teach how to do 2D movement, and rather teaches how to use a pre-made script, so in the end nothing about the movement is learnt, other than the inputs. A follow-up video on creating the actual script that does the movements would be useful to people learning, as it'd let them play around with their own ideas, instead of being limited to the pre-made script.
Bilip He said this tutorial is for beginners and he will not do a "propper" script for movement! This tutorial is not bad, for me was very helpfull. Probably you are an advanced developer who knows how to code, but i don't.
Hey everyone, if you are having some issue with crouch, the script provided in the discription has an error. To solve that, just open with your editor and go to line 67 (it is an if(!crouch) state) and remove the '!' on that line. The reason to do this is that is that the original check - if(!crouch) - is checking if player IS NOT crouching, and then set it to true. We don't want that. In fact, we want to know if player IS crouching. I hope this can help anyone else! Great tutorial though!
Thank you man! When my character started crouching automatically under some stuff he normally should be able to pass through I went to look for info here. I didn't know if you were referencing that problem but I tried doing what you said and it fixed it! Thanks :)
@gentoo Hey man, it seems you have a double = in your statement. Input.GetAxisRaw("Horizontal") should be multiplied by the runSpeed variable. The line should be: horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed; Hope this helps!
for those who are having a problem with the player clipping through the floor when releasing crouch button under an object, you need to edit the CharacterController2D script line 67(!crouch) change it to (crouch) to check if the player IS crouching AND line 64 the Move method you need to remove the first if statement. it basically means its only checking if there is an obstacle above you ONLY when you are pressing the crouch button which wont keep the collider disabled when you release the crouch. However when you remove the if(crouch) the first one in the Move method, it will check if there is an obstacle above you whether you are pressing down the crouch or not. meaning even when you release the crouch button it will STILL check is there an obstacle above you and therefore prevent the player from unchrouching until there is no obstacle above you.
I'm glad he explains where all of the variables are and what they do. Someone who wants to write code but can't type very fast can know when they are required to put an "arachibutyrophobia" in the code or when they can simply put "r." Super clear too. Thanks!
For anyone struggling with the player still falling through the ground, add a component (box collider 2D) to your terrain. It's the fastest way possible to do it and Brackeys didn't show it on his video. Hope it helped!
For those that are having the problem of not being able to jump, make sure that your GroundCheck is on the actual ground rather than on the bottom of the player.
My favorite parts of your tutorials is when: 1) you do something 2) I ask "... but why..?" 3) you go on to something else, and then 4) come back and answer my question.
i change Code and its now work for 3D games using UnityEngine; public class CharacterController : MonoBehaviour { [SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps. [Range(0, 1)] [SerializeField] private float m_CrouchSpeed = .36f; // Amount of maxSpeed applied to crouching movement. 1 = 100% [Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement [SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping; [SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character [SerializeField] private Transform m_GroundCheck; // A position marking where to check if the player is grounded. [SerializeField] private Transform m_CeilingCheck; // A position marking where to check for ceilings [SerializeField] private Collider m_CrouchDisableCollider; // A collider that will be disabled when crouching const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded private bool m_Grounded; // Whether or not the player is grounded. const float k_CeilingRadius = .2f; // Radius of the overlap circle to determine if the player can stand up private Rigidbody m_Rigidbody; private bool m_FacingRight = true; // For determining which way the player is currently facing. private Vector3 velocity = Vector3.zero; private void Awake() { m_Rigidbody = GetComponent(); } private void FixedUpdate() { m_Grounded = false; // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground // This can be done using layers instead but Sample Assets will not overwrite your project settings. Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].gameObject != gameObject) m_Grounded = true; } } public void Move(float move, bool crouch, bool jump) { // If crouching, check to see if the character can stand up if (!crouch) { // If the character has a ceiling preventing them from standing up, keep them crouching if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround)) { crouch = true; } } //only control the player if grounded or airControl is turned on if (m_Grounded || m_AirControl) { // If crouching if (crouch) { // Reduce the speed by the crouchSpeed multiplier move *= m_CrouchSpeed; // Disable one of the colliders when crouching if (m_CrouchDisableCollider != null) m_CrouchDisableCollider.enabled = false; } else { // Enable the collider when not crouching if (m_CrouchDisableCollider != null) m_CrouchDisableCollider.enabled = true; } // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody.velocity.y); // And then smoothing it out and applying it to the character m_Rigidbody.velocity = Vector3.SmoothDamp(m_Rigidbody.velocity, targetVelocity, ref velocity, m_MovementSmoothing); // If the input is moving the player right and the player is facing left... if (move > 0 && !m_FacingRight) { // ... flip the player. Flip(); } // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && m_FacingRight) { // ... flip the player. Flip(); } } // If the player should jump... if (m_Grounded && jump) { // Add a vertical force to the player. m_Grounded = false; m_Rigidbody.AddForce(new Vector2(0f, m_JumpForce)); } } private void Flip() { // Switch the way the player is labelled as facing. m_FacingRight = !m_FacingRight; // Multiply the player's x local scale by -1. Vector3 theScale = transform.localScale; theScale.x *= -1; transform.localScale = theScale; } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public CharacterController controller; public float runSpeed = 40f; float horizontalMove = 0f; bool jump = false; bool crouch = false; // Update is called once per frame void Update () { horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed; if (Input.GetButtonDown("Jump")) { jump = true; } if (Input.GetButtonDown("Crouch")) { crouch = true; } else if (Input.GetButtonUp("Crouch")) { crouch = false; } } void FixedUpdate () { // Move our character controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump); jump = false; } }
@@DivSharp I am in 2019.4 too and it doesn't work it says the : The name "Input" does not exist in the current context when i try ton enter playmode. But i checkerd and i did the same things as brackeys ...
Here’s some problems i faced and solutions i came up with. Player falling through floor / Rigid floor - Use TileMap Collider component on tilemap Couldn’t Move - Noticed my player was stuck in mid air, turned on air control to fix Couldn’t Jump: - Again due to player being stuck in mid air, and you can’t jump unless you are touching the ground. Noticed my ceiling and ground check were mixed up. Rearranged them and fixed the issue. (The ceiling check and ground check steps are required for jumping to work) Couldn’t Crouch - Go into the Character Controller script and press F3 or CTRL + F to use the “find” tool. Type in “!Crouch” (make sure it’s not case sensitive) and edit out that exclamation point.
There is a bug in new version of the script for movement. On line 45, I guess they accidentally put !crouch instead of crouch. This bug makes your character be always in the crouch position. To fix the bug, just open the "Character Controller 2D" code and edit that little "!".
I just spent quite some time trying to figure out why my player was always crouching, thank you so much. This solved it. P.S. The code has been updated and the line with the crouch error is now line 67.
AAAAAGAGHGHGHGHGHHGHGHGHAGHAGHAGHGHAGHAHHHHHHHHHHHHHHHHHHHHHHHHHGHGAGHGHGHGHHH!!!1!!!11! I worked about 3 hours on that problem and I didn't find it then I looked up your comment and deleted that little "!" and it's done! I don't fricking know should I laugh or cry.
For anyone who was having problems with your sprite crouching before you hit a wall. TLDR; change the size of line 17, K_CeilingRadius to better fit the character. The ceiling and ground checks make a radius that look out for the selected layers, these have a pre set size. You can make a circle and mess with sizes , then copy the size onto line 17, this way the invisible radius will be the size you needed.
I disagree that one shouldn't spend time with a character controller. I feel the opposite is true. Using a premade script is the worst possible choice, because you don't learn the basics. Movement teaches you more about unity than most people realize. For example, choosing HOW you move (modify velocity directly? Add forces? Transform and your own physics) will already teach you the differences between the kinds of forces unity uses. I've picked "modify velocity directly", for example, but that then causes other things to learn, particularly about how the physics engine works. Problems crop up, like moving into walls stopping falling, which teach you even more about the physics, and the solution naturally teaches you raycasts (as you want to make a check if your character is grounded, which requires raycasts). You also learn right here how gravity works, and that to solve this issue, you'll have to add gravity to your velocity "manually", so the movement into the wall doesn't cancel it out, which it normally does. And then there's moving platforms, which in itself offers multiple solutions, and teaches you even more. I wouldn't even have known about many of the intricacies of unity, especially when it comes to physics, if I had just picked a pre-set assets.
That is very true. It does depend on how deep you want to go into coding, but if you're serious about learning how to code games you should at least try it.
Fen Y it is simple! public float bulletSpeed; public int bullets; public int maxBullets; [SerializeField] private GameObject bulletPrefab; void Start(){ bullets = maxBullets; } void Shoot(){ if (Input.GetKeyDown("F")){ Bullet = Instantiate.bullet.object bullets -= 1; } }
if your character does a small bounce when you move on a flat surface try adding composite collider and add use composite onto the other collider, took me 8 hours to fix so ill save you some time
Man, thank GOD I found this channel. sad they are no longer plublishing videos anymore, but everything here is just SO HELPFULL!!!! Thanks guys, you've made an awesome job and learning developers around the world salute you!
thanks man i recreated everything for 2 hours just to find out that you can download it but a really great tutorial, hope to finish this playlist soon before the game jam starts. i am a beginner joining a game jam, which is really stupid if you ask me.
Turns out this set of colliders has weird interaction with platform effectors. The character can land on a platform with bottom side of the box while circle still ignores collision. If you are going to use platform effectors, replace the box with a vertical capsule collider full height long.
for those who has the problem where the jumping animation keep looping in mid air, in unity in assets go to the folder in which you keep the animation folder once you found your jumping animation click on it once, and then look at the inspector,un check the loop options,after that just to make sure u have a good animation,increase the duration between the first frame and the second frame of your jumping animation,that should do the trick
For anyone who turned up the gravity and are wondering why their character jitters when they land (or sometimes fall through the floor), set the collision detection on the player's rigidbody to continuous.
Just gonna mentioned they used this fox model design in the game Indigo Park as a mini game and I loved them using this! "I RECOGNIZE YOU" I said when I got into the minigame. Love it
Ok, so I feel compelled to add some of my own advice here. I was having the issue where my character is just constantly crouching upon hitting play. At first, I tried following Kota Pok (Parent of this comment thread) advice. His advice in his #4- the bit about changing the character controller script- that worked and made my character behave normally interms of being able to crouch and uncrouch. However, my character would allways stand up when I stop providing crouch input, even when there was a ceiling above him. In the end- I found that Brackey's chosen settings for his Player's "What is Ground" variable was throwing off my particular geometry for my colliders. The "What is Ground" variable can be modified in the "Characer Controller 2d (Script) section in your Player's Inspector in Unity. @3:10 Brackey's instructed us to set the "What Is Ground" variable to "Everything" and then unselect "Player" This ended up making everything mess up when it was time for detecting crouch collision. Basically, what I believe was happening (I'm still just a beginner), the "What is Ground" variable was being set to any of the other layers that we checked in that step. Consequently, when the collision check was being conducted between the ciling object and the ground object, whatever the ground was being set to was so far away that no collision was being detected between the two, and your player is being permitted to stand up because of that. So, what I did was- Like Kota Pok said in the parent comment, set "k_CeilingRadius" to .05f instead of .2f In Unity editor- Select Player and under Character Controller Script in the Player inspector, select the exact layer (or layers) you need to be the ground. For me, all of the platforms and terrain and obstacles I had set to my middle layer, so I could easily just set "What is Ground" to my middle layer. Do not use Kota Pok's 4th suggestion if this sounds like your problem
i dont understand what u mean by "kota pok's comment thread" is it someone that commented some advice here? cause im trying to find his comment but i can't
Ya I am curious about the "kota pok's comment thread" bit as well. I am having the same issue where my character is constantly crouching even when the crouch variable is set to false.
You could do a wallslide by raycasting to the left and right of the player to see if there is a wall, and checking if the player is moving towards said wall, where you could then lower the gravity the object feels while it's on the wall to make it fall slower to simulate a slide.
That's extremely easy. If (boolean "is touching wall" and boolean " is in the the air") {If (player presses jump button) Jump()} Wall jumping is enabled by default in Unity because you haven't programmed a way to check if the player is touching the ground, that needs to be implemented by the programmer.
Thank you, I'm trying that :D 3 booleans, one for touching ground tiles (previously tagged/with a ground class), one for walls and one for "while in the air" (when no ground or wall is checked, but it could be avoided if I just use wall and ground == false) Wonder if I can give types to tiles using Unity tilemap
Me: Does everything right Unity: Me: Wait, Unity, are you actually going to let me do this without you saying "NO" Unity: Yeah you win this time I will let you do what you want and it will work Me: aw thanks man Unity: RIGHT AFTER YOU FIX ALL THESE COMILER ERRORS! Me: AHHHHHHHH!
Hey, in case it goes over your head like it did for me because I missed it at the beginning of the video: don't forget to put Colliders on your floor and your platforms (a Tilemap Collider preferably!) or the player will fall and you'll scratch head wondering why!
Don't know bout you guys but i got it right the first time..payed a lot of attention :) thank you Brackeys, if one day i might get rich i'm gonna give you some of my earnings, cheers!
I LOVED THE WHOLE VIDEO :D Your way of explaining everything to a fine detail, what does the code do, what do variables do, situations and what not. A complete lesson/tutorial. I'll be enjoying all your content. This video makes everything seem so easy and workable... just how i like it
To everyone commenting about this being bad for beginners I believe he made the code for people who aren't invested into CS yet so he wants the beginners to not have to do the boring stuff and lose interest before they get to see how awesome CS is.
as a beginner who has never worked with unity before I found this video quite confusing... It seems like he's doing magic over there. He just writes 'jump' and through some wierd mysterious magic process it somehow works. Where did he tell the program how jumping should work? How did all of that happen. I am so confused right now....
Im guessing your problem was that your character could jump while in mid air, if that's the case, what was your solution because I cant seem to figure out how to get rid of it.
me at the beginning of the coding part: "i dont understand anything" In between the jump and crouch part: "I UNDERSTAND IT!!!!" at the end: "no i dont"
Just a note for people who may want to do this project. If you use the character controller script as given, then the player will always crouch. But if go to line 67 of the character controller code and change it to *if (crouch){* instead of *if (!crouch){* , then this will fix that issue.
If anyone is getting compiler errors there is a good chance that your Unity and Visual Studio aren't configured to work with each other yet and things like CharacterController2D aren't being recognized as classes. This is the solution below: In Unity Editor Go to Menu, Click on Edit -> Preferences -> External Tools -> External Script Editor. Set it to Visual Studio (your installed version of VS). Now in Menubar go to Edit -> Project Settings -> Player Settings -> Other Settings -> Under Configuration -> Check API Compatibility Level -> Change it to your installed .Net version. In my case I set it to .Net 4.x Then just restart VisualStudio and it should start recognizing the classes.
this doesnt't get me anywhere ... you should actually explain how to code those movements rather than use premade code. It's nice and all but at the end of the day I still don't get it how this works on the basic level and it takes me nowhere. It's just workaround for the actual topic
Ok I noticed one why the "always crouch" effect happens: when you define every layer, including the player's, as ground AND the ceiling check is within the player's box collider.
Hey what do you mean by "the ceiling check is withing the players box collider"? I changed the layer of the player from default to player but im still haveing the problem.
jump wasn't working so here is what i did to make it work: - create a layer and name it ground - assign your objects to what you want as the ground to the layer you just made - in characterController2d script > in private void awake() > add m_WhatIsGround = layerMask.getMask("ground"); -in playerMovement2d script > change getButtonDown > to just getButton
A Fix for: "NullReferenceException: Object reference not set to an instance of an object PlayerMovement.FixedUpdate () (at Assets/PlayerMovement.cs:26)": - Go to the player (click on him) - Under "Player Movement (Script)", next to "Controller"; if it says "None (Character Controller 2D)", you need to change this to "Player (Character Controller 2D)" by clicking the little bullet-point icon to the right of the text box and selecting "Player".
@@GilbertHernandez-eg8dx yeah it sucked lol, it was for my dads birthday and you just walk around with no air control and have to get all the grass but the controls are annoying and also I stopped the thread for delay back then cuz I didn’t know about subroutines so everything stopped whenever you got grass, it’s on my itch though the-mayday-man itch io
For all those whos crouch is not working there is a mistake in the downloaded controller. All you do to fix it is go to line 67 and change (!crouch) to (crouch), the script dev must of made a mistake in recent updates.
Hey so im doing the tutorial but his script looks completely different then mine and im trieng to do as him but it doesnt work so i would appreciate if you could help me out
Hi guys! I couldn't make my player jump (and i tried EVERYTHING) but I finally figured it out!! It's because I forgot to put the Ground/CeilingCheck objects under the Player objects (as children) xD Maybe this will help some of you
Is there a way to create levels using tilemaps and collision is already set up? Because I'm having struggle creating decent slope collision. Edit: Google is your friend.. if anyone else is looking for this -> there is a component called "tilemap collider 2d". Just add it to the gameobject with your ground and wall tiles.
Bit of a jump in this series dude. We've gone from setting up a basic scene in Ep.1, to you having a demonstration scene set out with player sprite, box colliders on the terrain etc. No explanation of how to set box colliders on a tileset :( Please don't skip ahead so quickly with no explanation!
@@Affe71 This is what the OP is complaining about. Legitimate complaint, I had the same one. Brackeys doesnt talk about how he set his scene up at all.
I will tell you a piece of advice download the whole project to save your head from all that headache I tried every single way as a beginner when you get better you may want to learn how he wrote everything and such but a beginner to beginner "DOWNLOAD THE WHOLE PROJECT " it's the third link in the video description!
If someone has the problem where the player just keeps falling trough ground/block,just make sure that the "thing" the player is falling on to has the BOX COLLIDER 2D,and not 3D!!!
And if you have a Tile map you should be able to: Add component > tilemap collider 2d > add and it should automatically setup the collider boxes based on the tilemap!
When brackeys mentioned a controller i plugged mine in and sure enough it worked! Tbh havent felt so happy about a controller working before .... maybe its because its 3 am and im still sat here coding? 🤔
I was having the issue below: NullReferenceException: Object reference not set to an instance of an object PlayerMovement.FixedUpdate () Here's the solution that worked for me: In Unity, click on your player and check the Player Movement script in the Inspector window. The Controller parameter will be set to "None (CharacterController2D)" by default. Click on the arrow on the right and change the controller to your player and that should do the trick!
Credit to a user by the name of Jay Tomk: for all getting the “NullExceptionError object not in instance of an object” or whatever it says, you have to click where it says “none(CharacterController2D)” in the playermovement component and change it from “none” to whatever you have your player character named
Make sure that you set the players 'Layer' to 'player' instead of 'default'. If you don't, your player will stay crouched at all times. Also, make sure you drag the box collider into the 'Crouch Disable Collider'. You do not have to change the code in any way it's correct.
ATTENTION: if you are having the problem that your character is not showing up when testing the game, your camera is not able to see it because of its z-axis. THE PROBLEM: click on your camera and goto clipping planes. If you look at the clipping planes it will probably show 0.3 in the near slot and 1000 in the far slot. This is the z-axis something needs to be on to show up. TO FIX THIS: Click on the item that is not working and change its z-axis to be within the range of the clipping ranges near and far values. (between 0.3 and 1000). OR change your near to -10000 and your far to 10000.
This tutorial is actually the best! I tried to make my own 2D controller but not like I expected this is like I expected controller like Play station and other controller movement!
Usually I like your tutorials, but this one isn't great. It doesn't really teach how to do 2D movement, and rather teaches how to use a pre-made script, so in the end nothing about the movement is learnt, other than the inputs. A follow-up video on creating the actual script that does the movements would be useful to people learning, as it'd let them play around with their own ideas, instead of being limited to the pre-made script.
I was thinking the exact same
Bilip He said this tutorial is for beginners and he will not do a "propper" script for movement! This tutorial is not bad, for me was very helpfull. Probably you are an advanced developer who knows how to code, but i don't.
I agree, it is much better to see the whole process than using something pre-made.
Feel free to read the code in the script provided to learn from that. This is how most programmers learn.
Good point
All hail lord Brackeys. You will be missed.
What happened?? :0
@@breadman3415 he left RUclips
@@mafhchodhri9699 why?
@@michaelross3061 he had video about it, just wanted to do something else for a change after doing gamedev stuff really long
@@breadman3415 he stopped making yt
Me: Copies exactly everything
Unity: Can I offer you 300 compiler errors?
"forgets to put a ; at the end of a line"
Try not to exactly copy it then or at least make sure you understand everything going on!
LOL
omg your not wrong
i still dont know how to add a player controller because i do everything the video says but unity hates me i guess
Hey everyone, if you are having some issue with crouch, the script provided in the discription has an error. To solve that, just open with your editor and go to line 67 (it is an if(!crouch) state) and remove the '!' on that line. The reason to do this is that is that the original check - if(!crouch) - is checking if player IS NOT crouching, and then set it to true. We don't want that. In fact, we want to know if player IS crouching. I hope this can help anyone else! Great tutorial though!
Okaeaeaej
Thank you man! When my character started crouching automatically under some stuff he normally should be able to pass through I went to look for info here. I didn't know if you were referencing that problem but I tried doing what you said and it fixed it! Thanks :)
@@robbybobbijoe You're welcome! XD
OMG thank you
mega thx
me: do everything correctly
unity: *n o*
Underrated comment and the same happened to me
@gentoo Hey man, it seems you have a double = in your statement. Input.GetAxisRaw("Horizontal") should be multiplied by the runSpeed variable. The line should be: horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
Hope this helps!
sameee
the script is outdated
@@SomeDudeOfficial oh, thank you William afton! I didnt knew it
"and know our character should be able to walk."
My Character during the Game Jam: best i can do is spin.
Bro I’m trying to make my character spin and I can’t figure it out.
@@landonlikesjazz3420 Z-axis probably not clamped in the rigidbody 2d settings. Check 5:04.
And
@@gaganpatidar8820 Yes. That is what I did. Freeze the Z I believe.
Your character live in spain whit out the "a"
for those who are having a problem with the player clipping through the floor when releasing crouch button under an object,
you need to edit the CharacterController2D script line 67(!crouch) change it to (crouch) to check if the player IS crouching AND line 64 the Move method you need to remove the first if statement. it basically means its only checking if there is an obstacle above you ONLY when you are pressing the crouch button which wont keep the collider disabled when you release the crouch. However when you remove the if(crouch) the first one in the Move method, it will check if there is an obstacle above you whether you are pressing down the crouch or not. meaning even when you release the crouch button it will STILL check is there an obstacle above you and therefore prevent the player from unchrouching until there is no obstacle above you.
thx man
I'm glad he explains where all of the variables are and what they do. Someone who wants to write code but can't type very fast can know when they are required to put an "arachibutyrophobia" in the code or when they can simply put "r." Super clear too. Thanks!
//Wow, that's the cleanest desktop I've ever seen.
probably a second windows account for recording
Love the fact that this comment is written as a comment in script.
@@neek01 or a second monitor with a second desktop
@@cloudythb Have you define the Layer of your Ground and the "What is Ground"(3:00) in the Character Controller?
//HE SETS IT UP
For those of you still having trouble with your character falling through the ground, set a Tilemap Collide 2D to your tilemap
how
@@pizzarolls9350 click on your tile map it's a component you can add onto it on the right side window
@@MrButterGuy thx but i found another solution u can add a box collision to your terrain and that made my character not fall through
Thank you god
Bless you!
For anyone struggling with the player still falling through the ground, add a component (box collider 2D) to your terrain. It's the fastest way possible to do it and Brackeys didn't show it on his video. Hope it helped!
my boy big brack still helping me even after the channel ended...
For those that are having the problem of not being able to jump, make sure that your GroundCheck is on the actual ground rather than on the bottom of the player.
Thank you so much!! i getting crazy because my Character didnt jump.
Jesus man.... I wouldn't get a clue i fucked that up xD
dude thank you
THANK YOUUUUUUUUUUUUUUUUUUUU
Thank you so much!!!
My favorite parts of your tutorials is when:
1) you do something
2) I ask "... but why..?"
3) you go on to something else, and then
4) come back and answer my question.
no
no
no
i change Code and its now work for 3D games
using UnityEngine;
public class CharacterController : MonoBehaviour
{
[SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps.
[Range(0, 1)] [SerializeField] private float m_CrouchSpeed = .36f; // Amount of maxSpeed applied to crouching movement. 1 = 100%
[Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
[SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character
[SerializeField] private Transform m_GroundCheck; // A position marking where to check if the player is grounded.
[SerializeField] private Transform m_CeilingCheck; // A position marking where to check for ceilings
[SerializeField] private Collider m_CrouchDisableCollider; // A collider that will be disabled when crouching
const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded
private bool m_Grounded; // Whether or not the player is grounded.
const float k_CeilingRadius = .2f; // Radius of the overlap circle to determine if the player can stand up
private Rigidbody m_Rigidbody;
private bool m_FacingRight = true; // For determining which way the player is currently facing.
private Vector3 velocity = Vector3.zero;
private void Awake()
{
m_Rigidbody = GetComponent();
}
private void FixedUpdate()
{
m_Grounded = false;
// The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
// This can be done using layers instead but Sample Assets will not overwrite your project settings.
Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
for (int i = 0; i < colliders.Length; i++)
{
if (colliders[i].gameObject != gameObject)
m_Grounded = true;
}
}
public void Move(float move, bool crouch, bool jump)
{
// If crouching, check to see if the character can stand up
if (!crouch)
{
// If the character has a ceiling preventing them from standing up, keep them crouching
if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround))
{
crouch = true;
}
}
//only control the player if grounded or airControl is turned on
if (m_Grounded || m_AirControl)
{
// If crouching
if (crouch)
{
// Reduce the speed by the crouchSpeed multiplier
move *= m_CrouchSpeed;
// Disable one of the colliders when crouching
if (m_CrouchDisableCollider != null)
m_CrouchDisableCollider.enabled = false;
} else
{
// Enable the collider when not crouching
if (m_CrouchDisableCollider != null)
m_CrouchDisableCollider.enabled = true;
}
// Move the character by finding the target velocity
Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody.velocity.y);
// And then smoothing it out and applying it to the character
m_Rigidbody.velocity = Vector3.SmoothDamp(m_Rigidbody.velocity, targetVelocity, ref velocity, m_MovementSmoothing);
// If the input is moving the player right and the player is facing left...
if (move > 0 && !m_FacingRight)
{
// ... flip the player.
Flip();
}
// Otherwise if the input is moving the player left and the player is facing right...
else if (move < 0 && m_FacingRight)
{
// ... flip the player.
Flip();
}
}
// If the player should jump...
if (m_Grounded && jump)
{
// Add a vertical force to the player.
m_Grounded = false;
m_Rigidbody.AddForce(new Vector2(0f, m_JumpForce));
}
}
private void Flip()
{
// Switch the way the player is labelled as facing.
m_FacingRight = !m_FacingRight;
// Multiply the player's x local scale by -1.
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public CharacterController controller;
public float runSpeed = 40f;
float horizontalMove = 0f;
bool jump = false;
bool crouch = false;
// Update is called once per frame
void Update () {
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
if (Input.GetButtonDown("Jump"))
{
jump = true;
}
if (Input.GetButtonDown("Crouch"))
{
crouch = true;
} else if (Input.GetButtonUp("Crouch"))
{
crouch = false;
}
}
void FixedUpdate ()
{
// Move our character
controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
jump = false;
}
}
thanks
thanks
@Cri Cat that's what she said
@@pineapplygames3340 OK
Mission complete
+1 respect
me: does everything he said
unity: nono we dont do that here
yea, it doesent work cus that code he is using is outdated.
@@danniitv o
@@danniitv nah it works
@@DivSharp You must down load the script and drop it to unity bro, the code still work but there something wrong and need to be fix to work :v
@@DivSharp I am in 2019.4 too and it doesn't work it says the : The name "Input" does not exist in the current context when i try ton enter playmode. But i checkerd and i did the same things as brackeys ...
Here’s some problems i faced and solutions i came up with.
Player falling through floor / Rigid floor
- Use TileMap Collider component on tilemap
Couldn’t Move
- Noticed my player was stuck in mid air, turned on air control to fix
Couldn’t Jump:
- Again due to player being stuck in mid air, and you can’t jump unless you are touching the ground. Noticed my ceiling and ground check were mixed up. Rearranged them and fixed the issue. (The ceiling check and ground check steps are required for jumping to work)
Couldn’t Crouch
- Go into the Character Controller script and press F3 or CTRL + F to use the “find” tool. Type in “!Crouch” (make sure it’s not case sensitive) and edit out that exclamation point.
Thank you so much. Now i can crouch :)
Thanks a bunch! The crouch issue was driving me crazy
In Germany we call this "Ehrenmann"
A R Thanks 🙏🏼
Thank you so much! you saved me so much time
I have used you for literally every step in my game dev journey, you are literally so good and useful. You make everything seem so easy
There is a bug in new version of the script for movement. On line 45, I guess they accidentally put !crouch instead of crouch. This bug makes your character be always in the crouch position. To fix the bug, just open the "Character Controller 2D" code and edit that little "!".
no its line 67
...
the movement speed line 21,33 is wrong..
I just spent quite some time trying to figure out why my player was always crouching, thank you so much. This solved it.
P.S. The code has been updated and the line with the crouch error is now line 67.
Merci :)
AAAAAGAGHGHGHGHGHHGHGHGHAGHAGHAGHGHAGHAHHHHHHHHHHHHHHHHHHHHHHHHHGHGAGHGHGHGHHH!!!1!!!11!
I worked about 3 hours on that problem and I didn't find it then I looked up your comment and deleted that little "!" and it's done! I don't fricking know should I laugh or cry.
At last, somebody found it
Man you are the best in this.
I watch your videos to practice my english because i speak spanish and i practicing my english SKILLS
I would like to see a tutorial like this for a top-down 2D game, like Zelda.
A Zelda series made in unity (Top Down as well)
ruclips.net/channel/UCSKZ683Om2H9yHLL1yX5dBQplaylists
So would I
me: strugles with making charachter jump.
Brackeys: now its time to make our charachter crouch and this is almost as simple as jumping.
For anyone who was having problems with your sprite crouching before you hit a wall. TLDR; change the size of line 17, K_CeilingRadius to better fit the character.
The ceiling and ground checks make a radius that look out for the selected layers, these have a pre set size. You can make a circle and mess with sizes , then copy the size onto line 17, this way the invisible radius will be the size you needed.
Thank you sooo much, this is the right answer, the problem is not in the code, it dependes on your character height and the position of tiles
Just went to Uni to study game design and development and that video have already helped me out in my first project.
I disagree that one shouldn't spend time with a character controller. I feel the opposite is true. Using a premade script is the worst possible choice, because you don't learn the basics.
Movement teaches you more about unity than most people realize. For example, choosing HOW you move (modify velocity directly? Add forces? Transform and your own physics) will already teach you the differences between the kinds of forces unity uses.
I've picked "modify velocity directly", for example, but that then causes other things to learn, particularly about how the physics engine works. Problems crop up, like moving into walls stopping falling, which teach you even more about the physics, and the solution naturally teaches you raycasts (as you want to make a check if your character is grounded, which requires raycasts).
You also learn right here how gravity works, and that to solve this issue, you'll have to add gravity to your velocity "manually", so the movement into the wall doesn't cancel it out, which it normally does.
And then there's moving platforms, which in itself offers multiple solutions, and teaches you even more.
I wouldn't even have known about many of the intricacies of unity, especially when it comes to physics, if I had just picked a pre-set assets.
That is very true. It does depend on how deep you want to go into coding, but if you're serious about learning how to code games you should at least try it.
mind you give me a source to learn all about this physic scripts?
I know things from different tutorials, trying them out and looking them up, I don't know a good tutorial that explains everything.
Fen Y it is simple!
public float bulletSpeed;
public int bullets;
public int maxBullets;
[SerializeField] private GameObject bulletPrefab;
void Start(){
bullets = maxBullets;
}
void Shoot(){
if (Input.GetKeyDown("F")){
Bullet = Instantiate.bullet.object
bullets -= 1;
}
}
i actually like walls stopping the player, it stops him but if hes sticcking to it too much, the force eventually pulls him.
but I apsolutely agree!
if your character does a small bounce when you move on a flat surface try adding composite collider and add use composite onto the other collider, took me 8 hours to fix so ill save you some time
I did that but it still didnt work:(
@@bopatomen8864 is the green collider one big shape or mutipul little green squares
Man, thank GOD I found this channel.
sad they are no longer plublishing videos anymore, but everything here is just SO HELPFULL!!!!
Thanks guys, you've made an awesome job and learning developers around the world salute you!
I didn't want to click on this video but it was better then the other videos I saw so I had to sub
thanks man i recreated everything for 2 hours just to find out that you can download it but a really great tutorial, hope to finish this playlist soon before the game jam starts. i am a beginner joining a game jam, which is really stupid if you ask me.
I know this comment is 5 months old but I'm having the same experience in a few weeks, how was it for you?
I mean that just means that you will understand it better than us "smart" people so you will really be the smart one
what is the point in downloading this?
I'm coming from 2029 and i can tell you Brackeys is still one of the best teachers
all i care about is that barca is awful
then why the fuck doesn’t this work
This tutorial: You can do this in maxim 25 minutes.
Unity: No
Me: After 5 hours working, you say " no"?
So true
I came back Brackeys for seeing your videos after 1 year!!
Turns out this set of colliders has weird interaction with platform effectors. The character can land on a platform with bottom side of the box while circle still ignores collision. If you are going to use platform effectors, replace the box with a vertical capsule collider full height long.
You can use the box and circle, but the box has to be smaller than the circle on the left and right edges.
Thank you! This solved so many problems in my project
Oh MrLuchs auch hier xD
bei mir funktionirt der bewegungs code nich
for those who has the problem where the jumping animation keep looping in mid air, in unity in assets go to the folder in which you keep the animation folder once you found your jumping animation click on it once, and then look at the inspector,un check the loop options,after that just to make sure u have a good animation,increase the duration between the first frame and the second frame of your jumping animation,that should do the trick
i found the problem with jumping animation should put exit time to 1
@@RHCIPHER No that just loops it if the animation doesnt fully play: (
@@cloudythb did you put a box collider 2D on your platform ?
nvm it's on a player controller then uuuuuh
player layer is not there when we choose what is ground please help
Miss these guys....
For anyone who turned up the gravity and are wondering why their character jitters when they land (or sometimes fall through the floor), set the collision detection on the player's rigidbody to continuous.
@G19tube Gkouk You need to create it. Go Layer -> Add layer... and name any User Layer(in video it is 8) as Player
@G19tube Gkouk save your script
This worked, thank you so much!! I've struggled with the problem of movement for 3 days now
I didn't realize it was so complicated to get a character to move.
Just gonna mentioned they used this fox model design in the game Indigo Park as a mini game and I loved them using this! "I RECOGNIZE YOU" I said when I got into the minigame. Love it
Ok, so I feel compelled to add some of my own advice here. I was having the issue where my character is just constantly crouching upon hitting play.
At first, I tried following Kota Pok (Parent of this comment thread) advice.
His advice in his #4- the bit about changing the character controller script- that worked and made my character behave normally interms of being able to crouch and uncrouch.
However, my character would allways stand up when I stop providing crouch input, even when there was a ceiling above him.
In the end- I found that Brackey's chosen settings for his Player's "What is Ground" variable was throwing off my particular geometry for my colliders. The "What is Ground" variable can be modified in the "Characer Controller 2d (Script) section in your Player's Inspector in Unity.
@3:10 Brackey's instructed us to set the "What Is Ground" variable to "Everything" and then unselect "Player"
This ended up making everything mess up when it was time for detecting crouch collision.
Basically, what I believe was happening (I'm still just a beginner), the "What is Ground" variable was being set to any of the other layers that we checked in that step. Consequently, when the collision check was being conducted between the ciling object and the ground object, whatever the ground was being set to was so far away that no collision was being detected between the two, and your player is being permitted to stand up because of that.
So, what I did was-
Like Kota Pok said in the parent comment, set "k_CeilingRadius" to .05f instead of .2f
In Unity editor- Select Player and under Character Controller Script in the Player inspector, select the exact layer (or layers) you need to be the ground. For me, all of the platforms and terrain and obstacles I had set to my middle layer, so I could easily just set "What is Ground" to my middle layer.
Do not use Kota Pok's 4th suggestion if this sounds like your problem
so, should the ground(the one I am walking on) and crouchpiece(the one I am trying to duck under) be same layers or diferent?
Bro you helped me
very very helpful thank you
i dont understand what u mean by "kota pok's comment thread" is it someone that commented some advice here? cause im trying to find his comment but i can't
Ya I am curious about the "kota pok's comment thread" bit as well. I am having the same issue where my character is constantly crouching even when the crouch variable is set to false.
Yes we want to see animation!! And wallsliding in 2d!!
yes , that's what we want :))
That would be great!
Please
You could do a wallslide by raycasting to the left and right of the player to see if there is a wall, and checking if the player is moving towards said wall, where you could then lower the gravity the object feels while it's on the wall to make it fall slower to simulate a slide.
Yeah, *YAY!
A wall grab and wall jump tutorial would be great!!!
Quill 18 has an amazing character controller that includes that if you don't want to wait for brackys to make one :)
That's extremely easy. If (boolean "is touching wall" and boolean " is in the the air") {If (player presses jump button) Jump()}
Wall jumping is enabled by default in Unity because you haven't programmed a way to check if the player is touching the ground, that needs to be implemented by the programmer.
Thank you, I'm trying that :D
3 booleans, one for touching ground tiles (previously tagged/with a ground class), one for walls and one for "while in the air" (when no ground or wall is checked, but it could be avoided if I just use wall and ground == false)
Wonder if I can give types to tiles using Unity tilemap
Or you can add a physics material and bump the friction up to one
Amazing video! Clearly explained everything, I was trying for hours to get this to work but once I watched your video it worked in minutes.
Thanks Brackeys, my character finally moves. Thanks for making this tutorial, it really helped .👍
Me: Does everything right
Unity:
Me: Wait, Unity, are you actually going to let me do this without you saying "NO"
Unity: Yeah you win this time I will let you do what you want and it will work
Me: aw thanks man
Unity: RIGHT AFTER YOU FIX ALL THESE COMILER ERRORS!
Me: AHHHHHHHH!
I can 100% relate to that
Update to a newer version, unity 2020.2 has no errors.
player layer is not there when we choose what is ground please help
@@sameerop2100 you have to create the layer yourself i assume. Theres an ADD LAYER setting when you choose a layer.
@@polly5229 thanks for your help I figured it out now
Hey, in case it goes over your head like it did for me because I missed it at the beginning of the video: don't forget to put Colliders on your floor and your platforms (a Tilemap Collider preferably!) or the player will fall and you'll scratch head wondering why!
Hahaha a few hours of scratching your head
@stellarestuary thanks to you i didn't have to spend more than 30 min :P
yes like me . scratched my head into oblivion. Thank you!!!
Don't know bout you guys but i got it right the first time..payed a lot of attention :) thank you Brackeys, if one day i might get rich i'm gonna give you some of my earnings, cheers!
I LOVED THE WHOLE VIDEO :D
Your way of explaining everything to a fine detail, what does the code do, what do variables do, situations and what not. A complete lesson/tutorial.
I'll be enjoying all your content. This video makes everything seem so easy and workable... just how i like it
To everyone commenting about this being bad for beginners I believe he made the code for people who aren't invested into CS yet so he wants the beginners to not have to do the boring stuff and lose interest before they get to see how awesome CS is.
bro no matter when they do it it wont change the fun factor
as a beginner who has never worked with unity before I found this video quite confusing... It seems like he's doing magic over there. He just writes 'jump' and through some wierd mysterious magic process it somehow works. Where did he tell the program how jumping should work? How did all of that happen. I am so confused right now....
@@kilianlang3316 this is a joke right? r/wooosh? now IM confused :/
C++ and C# is not the same (I've learned C++ but I need for Unity C# :/)
@@kilianlang3316 Then you shouldn't start off with this video then...
dude, you are awesome! as a beginner, these vids are SUPER helpful!
I know I'm too late for this video, but your explanation helped me to solve double jump problem!!! So thx ^^
Im guessing your problem was that your character could jump while in mid air, if that's the case, what was your solution because I cant seem to figure out how to get rid of it.
We don't want the player to walk ontop of himself hahaha, made my day!
Me: tries to drag and drop the character controller. Unity: N O
same
@Sir monkeyman thanks
@Sir monkeyman I did that and it still will not work
drag it into assets and from there drag it onto your player
@@tylerfrancois2194 tried it didn't work
me at the beginning of the coding part: "i dont understand anything"
In between the jump and crouch part: "I UNDERSTAND IT!!!!"
at the end: "no i dont"
Just a note for people who may want to do this project. If you use the character controller script as given, then the player will always crouch. But if go to line 67 of the character controller code and change it to *if (crouch){* instead of *if (!crouch){* , then this will fix that issue.
This is exactly what I needed thank you!
If anyone is getting compiler errors there is a good chance that your Unity and Visual Studio aren't configured to work with each other yet and things like CharacterController2D aren't being recognized as classes. This is the solution below:
In Unity Editor Go to Menu, Click on Edit -> Preferences -> External Tools -> External Script Editor. Set it to Visual Studio (your installed version of VS).
Now in Menubar go to Edit -> Project Settings -> Player Settings -> Other Settings -> Under Configuration -> Check API Compatibility Level -> Change it to your installed .Net version. In my case I set it to .Net 4.x
Then just restart VisualStudio and it should start recognizing the classes.
Man,,, how can i THANK YOU!!!!
This helps SO MUCH Thank you
Very very much tq may u live 109yrs
thanks but still doesn't recognise it
thanks dude, cant thank enough
this doesnt't get me anywhere ... you should actually explain how to code those movements rather than use premade code. It's nice and all but at the end of the day I still don't get it how this works on the basic level and it takes me nowhere. It's just workaround for the actual topic
I tried learning but it's so boring just do what the tutorial says
that's how it was when I started.
@Scar Or you can just accept that people do things differently than each other and not try to shoot down a potential future game dev.
@Scar Im doing it as a hobby m8 I'll learn l8er
@Scar You're making me think I shouldn't become a game dev then...
Ok I noticed one why the "always crouch" effect happens: when you define every layer, including the player's, as ground AND the ceiling check is within the player's box collider.
Thank you so much i have been trying to fix this for over an hour
Hey what do you mean by "the ceiling check is withing the players box collider"? I changed the layer of the player from default to player but im still haveing the problem.
Nevermind! there was an error in brackeys code from the description on line 67. There wasnt supposed to be an ! infront of the word crouch
@@MurderApp thank you so much bro
@@MurderApp Thank you very much, saved me a headache.
Brackets you are the best ever love your channel so much you actually explain it instead of telling us to do it
For anyone else having trouble with the jump, make sure your ground Layer is set to something other than default
thanks man
Didnt change anything for me
jump wasn't working so here is what i did to make it work:
- create a layer and name it ground
- assign your objects to what you want as the ground to the layer you just made
- in characterController2d script > in private void awake() > add m_WhatIsGround = layerMask.getMask("ground");
-in playerMovement2d script > change getButtonDown > to just getButton
Sorry, how do you create a new layer?
how did you get it to work
thank u bro!!!!!!
thx
RUclipsr: *makes a game making tutorial*
Game Monkey ad: Is For Me???
Same lol
For those people who can't afford to donate on patreon you can kind of pay him by waiting till the very end of the video for another ad to show up
A Fix for: "NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.FixedUpdate () (at Assets/PlayerMovement.cs:26)":
- Go to the player (click on him)
- Under "Player Movement (Script)", next to "Controller"; if it says "None (Character Controller 2D)", you need to change this to "Player (Character Controller 2D)" by clicking the little bullet-point icon to the right of the text box and selecting "Player".
Thankyou so much I didn't know why this was happening
Thanks a trillion!!! I was just about to quit, u just saved me
thank you so so much, i almost restarted.
You saved me Mr. Man, you were my only hope.
you are a god, thank you so much
You should do a series of teaching the Unity documentation/API.
the problem of newbie watching tutorials is when it is not updated, and you start encountering errors
I love it. Making a platformer where you control a riding sheep and didn't have a script to use. This really helped!
that game sounds fun, did you made it?
@@GilbertHernandez-eg8dx yeah it sucked lol, it was for my dads birthday and you just walk around with no air control and have to get all the grass but the controls are annoying and also I stopped the thread for delay back then cuz I didn’t know about subroutines so everything stopped whenever you got grass, it’s on my itch though the-mayday-man itch io
For those who can't jump:
Move the Groundcheck (of your player) a bit more down. It fixed my player's jump.
still not working
ruclips.net/video/n4N9VEA2GFo/видео.html
this saved me, thank you
If your using basic shapes turn on air control to move
Dude thank you this solved my issue. Could you explain why this fixes it? I set up my colliders exactly like he did
@@melon5345 if your character is shaped weirdly and has different colliders than it should it might clip into the ground
For all those whos crouch is not working there is a mistake in the downloaded controller.
All you do to fix it is go to line 67 and change (!crouch) to (crouch), the script dev must of made a mistake in recent updates.
Thank you so much, you actually saved me!!!!!! I was so confused
crouch is not working
@Huran How did you solve iy then?
wow thank you so much :D
this guy is soo underrated !!
Hey so im doing the tutorial but his script looks completely different then mine and im trieng to do as him but it doesnt work so i would appreciate if you could help me out
Hi guys! I couldn't make my player jump (and i tried EVERYTHING) but I finally figured it out!! It's because I forgot to put the Ground/CeilingCheck objects under the Player objects (as children) xD Maybe this will help some of you
14 hours after you commented you already helped me lmao thanks
@@littledude52 Bahahha that's amazing!! xD Glad I could help
Is there a way to create levels using tilemaps and collision is already set up? Because I'm having struggle creating decent slope collision.
Edit: Google is your friend.. if anyone else is looking for this -> there is a component called "tilemap collider 2d". Just add it to the gameobject with your ground and wall tiles.
Thank you!
many kisses
Thankyou so much!!
u sir, are a gentlemen and a scholar
No way you just saved me XD
Coding your own games is easier than you think
Jovan Novakovic you know, YoU sHouLd takE ThiS onLinE UniTY cOURse oN UDeMY.
IT STARTED PLAYING AS I WAS READING YOUR COMMENT.
But have you heard about skillshare?
Hello, this is code monkeyand
Sometimes I consider getting Adblock to save my sanity, but then I remember that the ads support the users I watch
Amen brackeys, always making my day better.. :)
very useful for me
i cant understand speech but i follow video and than i get a technique
thanks very much
Bit of a jump in this series dude. We've gone from setting up a basic scene in Ep.1, to you having a demonstration scene set out with player sprite, box colliders on the terrain etc. No explanation of how to set box colliders on a tileset :( Please don't skip ahead so quickly with no explanation!
" No explanation of how to set box colliders on a tileset", dude... click the tileset and click the box collider. there is nothing hard about that.
@@Affe71 took me a solid few minutes to figure out, i put the box collider on the wrong thing shit happens
@@toystoryjohn8457 box colliders work but i would use tile map colliders if all you want is for the player to walk on tiles.
@@Affe71 i tried using those but it wasnt working with a sloped ground right
@@Affe71 This is what the OP is complaining about. Legitimate complaint, I had the same one. Brackeys doesnt talk about how he set his scene up at all.
when you find that you are unable to crouch go to "Character Controller 2D" then go to line 67 change (!Crouch)
to (Crouch)
Thanks, that worked!
thanks
you're very attractive
Thx. My box collider was just turning on and off in infinit loop- this (!Crouch) was the problem:)
Nice glasses my man!
So now we wanna do thi-
(shows dramatic trailer)
*BRUH THAT IS SO HARD*
ruclips.net/video/YzCF3zbfUE0/видео.html
17:58. Don’t mind me I’m just marking my spot
my dear friends he forgot to mention that u have to add box collider to both forground elements also
lol thats so obvious watch the first episode dumbass
WOW!! I just learned something new that I wasn't trying to learn.
You should put the background as a child of the camera so that it follows it.
I'm new at this so ima make a jumping moving square
I'm trying the same but with a circle
Me: Follows The Tutorial in every littel step
Unity: May we intrest you in 333 Errors?
How much people are here in 2020 trying to be an Indie Game Development like me :) ?
Me! 😅
me too!
me
Let's me party
Me
I don't know how you are so good. Hope you come back to making this amazing content!
I forgot to freeze the rotation so when I started the game my player was drunk.
same
and if you keep the camera on the person it's amazing XD
@@extremetitan2847 I do that too
I will tell you a piece of advice download the whole project to save your head from all that headache I tried every single way as a beginner when you get better you may want to learn how he wrote everything and such but a beginner to beginner "DOWNLOAD THE WHOLE PROJECT " it's the third link in the video description!
If someone has the problem where the player just keeps falling trough ground/block,just make sure that the "thing" the player is falling on to has the BOX COLLIDER 2D,and not 3D!!!
thanks so much i overlook alot
And if you have a Tile map you should be able to:
Add component > tilemap collider 2d > add
and it should automatically setup the collider boxes based on the tilemap!
@@fazilllay WE LIKE U
When brackeys mentioned a controller i plugged mine in and sure enough it worked! Tbh havent felt so happy about a controller working before .... maybe its because its 3 am and im still sat here coding? 🤔
I was having the issue below:
NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.FixedUpdate ()
Here's the solution that worked for me:
In Unity, click on your player and check the Player Movement script in the Inspector window. The Controller parameter will be set to "None (CharacterController2D)" by default. Click on the arrow on the right and change the controller to your player and that should do the trick!
OH my... thank you so much lol
YES ! THIS IS IT! TY !!!!!!
We want nex series of character ctrl + animation + particles
Credit to a user by the name of Jay Tomk: for all getting the “NullExceptionError object not in instance of an object” or whatever it says, you have to click where it says “none(CharacterController2D)” in the playermovement component and change it from “none” to whatever you have your player character named
Still doesn't work, idk
@@giventeacher5653 same problem
You have to Drag your player to "controller" slot in PlayerMovement in unity
Thanks
We miss you man
Are you planning to make this a series Brackeys?
Make sure that you set the players 'Layer' to 'player' instead of 'default'. If you don't, your player will stay crouched at all times. Also, make sure you drag the box collider into the 'Crouch Disable Collider'. You do not have to change the code in any way it's correct.
It took me days to identify my mistake. I hope this helps
Oh my god, thank you! I've been looking for days too for this now haha...
ATTENTION: if you are having the problem that your character is not showing up when testing the game, your camera is not able to see it because of its z-axis.
THE PROBLEM: click on your camera and goto clipping planes. If you look at the clipping planes it will probably show 0.3 in the near slot and 1000 in the far slot. This is the z-axis something needs to be on to show up.
TO FIX THIS:
Click on the item that is not working and change its z-axis to be within the range of the clipping ranges near and far values. (between 0.3 and 1000).
OR
change your near to -10000 and your far to 10000.
This tutorial is actually the best! I tried to make my own 2D controller but not like I expected this is like I expected controller like Play station and other controller movement!