2D Movement in Unity (Tutorial)
Why Stack Overflow recommends it
Stack Overflow users link it as the standard beginner reference for 2D Unity movement, both when answering jump, crouch and animation questions and as the source of the code that askers copied.
Recommended by 8 people across 7 different months, 2019 to 2023.
What it is
A 21-minute Brackeys tutorial that builds a 2D platformer character controller in Unity from scratch, covering running, jumping, crouching and ground checks. It comes with a downloadable project, a character controller script and sprite assets.
What people said
Strong rec Nicolas · 2023-11 · Stack Overflow · on “Player Jumping Very High Every Few Jumps”
I can't help you debugging your script step by step. If you're a complete beginner I highly suggest you watch the video [this video] I linked above. It basically guides you through creating a 2d platformer controller from scratch and teaches you about good practices while doing so. No offense, but your script is messy and has other issues. There's no guarantee that what I suggested works without other modifications, as you just found out. Spend the time and learn good practices, be patient and it will work at some point.
Recommends janavarro · 2019-05 · Stack Overflow · on “why does my jump animation stops in middle and return to idle?”
If you are starting to use Unity I suggest you to follow this man's tutorial, he also teaches good practises and it's easy to understand. In this video he does what you want he has many other tutorials (this video is for Unity2D but it can help you with 3D too) [this video]
Recommends Tim Hunter · 2019-05 · Stack Overflow · on “Crouching issues in Unity”
Brackeys on Youtube as a nice video on 2D Movement [this video] including crouching if you are interested in checking out his solution.
Recommends Spencer Stream · 2020-02 · Stack Overflow · on “How can I check if my 2D character is in the air in Unity2D?”
Instead of doing a raycast straight down, you could also cast a circle around the player's feet. You will need to add an empty ground check game object as a child of your player and position its transform at the player's feet. Next, you will need to define what layers count as the ground in the inspector for the m_WhatIsGround LayerMask. Then in FixedUpdate() check if the ground check transform is within some radius to the ground. // A mask determining what is ground to the character [SerializeField] private LayerMask m_WhatIsGround; // A position marking where to check if the player is grounded. [SerializeField] private Transform m_GroundCheck; // Radius of the overlap circle to determine i
Recommends SeLeCtRa · 2021-01 · Stack Overflow · on “Why aren't the animations working for this 2D unity character controller script”
Before asking please read [Question Asking Guideline] ( [LINK] ). Regarding to question, there are tons of youtube videos. Did you try any of them? with just 3 word you could find solution. Here is link to one of them. Unity 2D Character Animation [this video]
Recommends DavidA_ · 2021-05 · Stack Overflow · on “Movement script does not work (unity, C#)”
I must say that that's an unusual way to make a movement script that's using a rigidbody. what you could do instead is add forces on an axis. For example, if the player pressed a, the script would know and would add a force from the z axis. For the jump, you could have a ground check. here are a couple movement script tutorials explaining how to make a good movement script : [this video] this video is about how to use physics to make a full 2D player movement script. [LINK] this one is about different ways on how you can make a 2D player movement script, this will help you a lot, I promise! [LINK] and last but not least, this one is about how to make a 2D player movement script using the transfor
Recommends B3NII · 2021-08 · Stack Overflow · on “Cant jump :What am i missing?”
I'm assuming that you are following this tutorial: [this video] According to this, the problem is not with the code, but you probably missed something in Unity. That happens all the time. What I can imagine as problem is that you forgot to set the Jump button in the Edit > Project Settings > Input Manager section or you mistyped it. Of course, several other problems can be imagined, such as you forgot to put the script on a Game Object, so it is not functioning. My last idea is, that you didn't give a reference for the CharacterController2D in the Unity Inspector. As I said, I don't think the problem is with the code. Hope I could help.
Recommends Yeriwen · 2023-05 · Stack Overflow · on “Unity 2D Platformer: Jump animation breaks when Player Object turned into a Prefab. Any solutions?”
I'm currently working on a 2D Platformer in Unity. I followed along Brackeys Tutorials (will post links below) and everything works like intended, except when I turn my Player Object into a prefab. Then suddenly my Jump Animation breaks for some reason. Does anyone know a solution for this problem, because im not sure whether it's a programming problem or a unity related issue. Tutorials I used: #1 [this video] #2 [LINK] Bugged Animation video: [LINK] The left player character in the video is the prefab with the bugged animation. Would be really awesome if someone can help me :) Kind Regards, Jean-Pierre I've tried changing some of my code, also tried re-animating the Object as a Prefab, and sear
Recommends Nicolas · 2023-11 · Stack Overflow · on “Player Jumping Very High Every Few Jumps”
you're doing input handling in `FixedUpdate`. This is a bad idea which can lead to undesired behaviour. In this instance however I think the whole cjump Invoke stuff could be the issue. My best guess is that you whole jumping logic is called twice before your `Invoke("CJump",0.012f) call goes trough, meaning you're adding your jump force twice in some instances. Try to restructure the whole script and separate input handling from physics handling. Brackeys has a really good beginners guide covering the topic [this video]
Cites Javascript noob · 2019-03 · Stack Overflow · on “How do I add MonoBehavoir to sprite (Player)?”
I am watching a brackeys video( [this video] ) And the script he used wouldn't work( [LINK] ) The error is: Can't add script CallBackExcuter! Needs to derive from MonoBehavoir