2D Movement in Unity (Tutorial)

Sdílet
Vložit
  • čas přidán 27. 08. 2024
  • Let’s give our player some moves!
    ● Check out Skillshare: skl.sh/brackeys7
    ● Character Controller: bit.ly/2MQAkmu
    ● Download the Project: bit.ly/2KPx7pX
    ● Get the Assets: bit.ly/2KOkwjt
    ❤️ Donate: www.paypal.com...
    ····················································································
    ♥ Subscribe: bit.ly/1kMekJV
    ● Website: brackeys.com/
    ● Facebook: / brackeys
    ● Twitter: / brackeystweet
    ········································­­·······································­·­····
    ► All content by Brackeys is 100% free. We believe that education should be available for everyone.
    ❤️ Donate: www.paypal.com...
    ········································­­·······································­·­····
    ♪ "ES_Freekin'_Fretless_3" - Mattias Andreasson" by Epidemic Sound
    ♪ "ES_Dress Code_Black - oomiee" by Epidemic Sound

Komentáře • 6K

  • @sink899
    @sink899 Před 6 lety +4776

    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.

    • @DukaSoft
      @DukaSoft Před 6 lety +287

      I was thinking the exact same

    • @UBassBoostHD
      @UBassBoostHD Před 6 lety +301

      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.

    • @DanielGriffiths
      @DanielGriffiths Před 6 lety +154

      I agree, it is much better to see the whole process than using something pre-made.

    • @StillNight77
      @StillNight77 Před 6 lety +214

      Feel free to read the code in the script provided to learn from that. This is how most programmers learn.

    • @felipe18383
      @felipe18383 Před 6 lety +25

      Good point

  • @thepizzafoogle5481
    @thepizzafoogle5481 Před 3 lety +1263

    Me: Copies exactly everything
    Unity: Can I offer you 300 compiler errors?

    • @sirtenders2965
      @sirtenders2965 Před 3 lety +88

      "forgets to put a ; at the end of a line"

    • @tomtin4363
      @tomtin4363 Před 3 lety +34

      Try not to exactly copy it then or at least make sure you understand everything going on!

    • @xDTHECHEMISTx
      @xDTHECHEMISTx Před 3 lety +1

      LOL

    • @UnhingedDucky
      @UnhingedDucky Před 3 lety +5

      omg your not wrong

    • @UnhingedDucky
      @UnhingedDucky Před 3 lety +21

      i still dont know how to add a player controller because i do everything the video says but unity hates me i guess

  • @Mistbu
    @Mistbu Před 3 lety +1072

    All hail lord Brackeys. You will be missed.

    • @breadman3415
      @breadman3415 Před 3 lety +12

      What happened?? :0

    • @mafhchodhri9699
      @mafhchodhri9699 Před 3 lety +22

      @@breadman3415 he left CZcams

    • @michaelross3061
      @michaelross3061 Před 3 lety +6

      @@mafhchodhri9699 why?

    • @oskari3659
      @oskari3659 Před 3 lety +19

      @@michaelross3061 he had video about it, just wanted to do something else for a change after doing gamedev stuff really long

    • @syllebrix5784
      @syllebrix5784 Před 3 lety +5

      @@breadman3415 he stopped making yt

  • @someidiotontheinternet5615
    @someidiotontheinternet5615 Před 4 lety +1844

    me: do everything correctly
    unity: *n o*

    • @ZeonplayzYt
      @ZeonplayzYt Před 4 lety +43

      Underrated comment and the same happened to me

    • @CreeperMedia7801
      @CreeperMedia7801 Před 4 lety +9

      @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!

    • @technofreaktk7094
      @technofreaktk7094 Před 3 lety +1

      sameee

    • @SomeDudeOfficial
      @SomeDudeOfficial Před 3 lety +7

      the script is outdated

    • @someidiotontheinternet5615
      @someidiotontheinternet5615 Před 3 lety +2

      @@SomeDudeOfficial oh, thank you William afton! I didnt knew it

  • @MrButterGuy
    @MrButterGuy Před 4 lety +710

    For those of you still having trouble with your character falling through the ground, set a Tilemap Collide 2D to your tilemap

    • @pizzarolls9350
      @pizzarolls9350 Před 4 lety +1

      how

    • @MrButterGuy
      @MrButterGuy Před 4 lety +16

      @@pizzarolls9350 click on your tile map it's a component you can add onto it on the right side window

    • @pizzarolls9350
      @pizzarolls9350 Před 4 lety +20

      @@MrButterGuy thx but i found another solution u can add a box collision to your terrain and that made my character not fall through

    • @just_a_mango
      @just_a_mango Před 4 lety

      Thank you god

    • @Rose-ez9vf
      @Rose-ez9vf Před 4 lety +1

      Bless you!

  • @ItsMeHoodson
    @ItsMeHoodson Před 3 lety +301

    "and know our character should be able to walk."
    My Character during the Game Jam: best i can do is spin.

    • @landonlikesjazz3420
      @landonlikesjazz3420 Před 3 lety +1

      Bro I’m trying to make my character spin and I can’t figure it out.

    • @PlumCastleonBlitz
      @PlumCastleonBlitz Před 3 lety +2

      @@landonlikesjazz3420 Z-axis probably not clamped in the rigidbody 2d settings. Check 5:04.

    • @willluciano6390
      @willluciano6390 Před 3 lety

      And

    • @PlumCastleonBlitz
      @PlumCastleonBlitz Před 3 lety

      @@gaganpatidar8820 Yes. That is what I did. Freeze the Z I believe.

    • @bashrock2548
      @bashrock2548 Před 2 lety

      Your character live in spain whit out the "a"

  • @dufwine3621
    @dufwine3621 Před rokem +100

    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!

    • @MAS9Nine
      @MAS9Nine Před rokem +1

      Okaeaeaej

    • @robbybobbijoe
      @robbybobbijoe Před rokem +4

      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 :)

    • @dufwine3621
      @dufwine3621 Před rokem +1

      @@robbybobbijoe You're welcome! XD

    • @laubi5353
      @laubi5353 Před rokem +2

      OMG thank you

    • @Rainbowgunsh
      @Rainbowgunsh Před rokem +2

      mega thx

  • @reaper_artwave
    @reaper_artwave Před rokem +13

    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.

  • @mrkathooloo5711
    @mrkathooloo5711 Před 4 lety +133

    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.

  • @isaiah4967
    @isaiah4967 Před 4 lety +378

    //Wow, that's the cleanest desktop I've ever seen.

    • @neek01
      @neek01 Před 4 lety +12

      probably a second windows account for recording

    • @BryanKeferl
      @BryanKeferl Před 4 lety +44

      Love the fact that this comment is written as a comment in script.

    • @AhmedAhmed-dv4ch
      @AhmedAhmed-dv4ch Před 4 lety +3

      @@neek01 or a second monitor with a second desktop

    • @nakrodus9932
      @nakrodus9932 Před 3 lety

      @@cloudythb Have you define the Layer of your Ground and the "What is Ground"(3:00) in the Character Controller?

    • @GG-kx4ct
      @GG-kx4ct Před 3 lety +2

      //HE SETS IT UP

  • @anchovy5325
    @anchovy5325 Před 3 lety +174

    me: does everything he said
    unity: nono we dont do that here

    • @danniitv
      @danniitv Před 3 lety +6

      yea, it doesent work cus that code he is using is outdated.

    • @anchovy5325
      @anchovy5325 Před 3 lety +1

      @@danniitv o

    • @zionlee1004
      @zionlee1004 Před 3 lety +2

      @@danniitv nah it works

    • @nyandesu4664
      @nyandesu4664 Před 3 lety +1

      @@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

    • @lerougeun4099
      @lerougeun4099 Před 3 lety +3

      @@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 ...

  • @thenecromancer4113
    @thenecromancer4113 Před 2 lety +24

    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!

  • @sykoo
    @sykoo Před 6 lety +412

    These intros keep getting better and better. 👀 Is it weird that I keep replaying them? They just feel so satisfying.

  • @ichifish
    @ichifish Před 5 lety +117

    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.

  • @Ithee_The_Fox
    @Ithee_The_Fox Před rokem +9

    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!

  • @tzeakarecords5055
    @tzeakarecords5055 Před 3 lety +42

    This tutorial: You can do this in maxim 25 minutes.
    Unity: No
    Me: After 5 hours working, you say " no"?

  • @dinovidakovic9486
    @dinovidakovic9486 Před 5 lety +559

    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 "!".

    • @starvedflamingo3820
      @starvedflamingo3820 Před 5 lety +40

      no its line 67
      ...
      the movement speed line 21,33 is wrong..

    • @salazarseth1
      @salazarseth1 Před 5 lety +51

      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.

    • @DamienGa
      @DamienGa Před 5 lety +3

      Merci :)

    • @pascal8765
      @pascal8765 Před 5 lety +12

      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.

    • @adityasanjaya838
      @adityasanjaya838 Před 5 lety +4

      At last, somebody found it

  • @fy8798
    @fy8798 Před 6 lety +316

    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.

    • @sensei9767
      @sensei9767 Před 6 lety +9

      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.

    • @manakaYT
      @manakaYT Před 6 lety +12

      mind you give me a source to learn all about this physic scripts?

    • @sensei9767
      @sensei9767 Před 6 lety +3

      I know things from different tutorials, trying them out and looking them up, I don't know a good tutorial that explains everything.

    • @fjjfccjjgvnkcbjb157
      @fjjfccjjgvnkcbjb157 Před 6 lety +1

      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;
      }
      }

    • @vaskedagame880
      @vaskedagame880 Před 6 lety +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!

  • @SMT-ks8yp
    @SMT-ks8yp Před 3 lety +27

    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.

    • @lukenelson9845
      @lukenelson9845 Před rokem

      You can use the box and circle, but the box has to be smaller than the circle on the left and right edges.

  • @guvoia
    @guvoia Před 7 měsíci +3

    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

  • @FREEGEMS
    @FREEGEMS Před 4 lety +38

    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.

    • @Shiro1908
      @Shiro1908 Před 4 lety +2

      Thank you so much. Now i can crouch :)

    • @morgangalvin8893
      @morgangalvin8893 Před 4 lety

      Thanks a bunch! The crouch issue was driving me crazy

    • @PryZ_z
      @PryZ_z Před 4 lety +2

      In Germany we call this "Ehrenmann"

    • @carl_yt2419
      @carl_yt2419 Před 4 lety

      A R Thanks 🙏🏼

    • @cadence1108
      @cadence1108 Před 4 lety

      Thank you so much! you saved me so much time

  • @jazzallen6537
    @jazzallen6537 Před 4 lety +17

    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

  • @GibbaGods
    @GibbaGods Před 3 lety +13

    me: strugles with making charachter jump.
    Brackeys: now its time to make our charachter crouch and this is almost as simple as jumping.

  • @foxdemon194v
    @foxdemon194v Před 2 lety +6

    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.

    • @gatjensb
      @gatjensb Před rokem

      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

  • @Without_Context
    @Without_Context Před 4 lety +378

    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;
    }
    }

  • @mpixel2058
    @mpixel2058 Před 6 lety +72

    I would like to see a tutorial like this for a top-down 2D game, like Zelda.

  • @im_skrunkly
    @im_skrunkly Před 2 lety +1

    my boy big brack still helping me even after the channel ended...

  • @BoxChicken137
    @BoxChicken137 Před 3 lety +7

    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

    • @bopatomen8864
      @bopatomen8864 Před 3 lety

      I did that but it still didnt work:(

    • @BoxChicken137
      @BoxChicken137 Před 3 lety

      @@bopatomen8864 is the green collider one big shape or mutipul little green squares

  • @mrman7009
    @mrman7009 Před 4 lety +46

    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".

  • @7Edgard
    @7Edgard Před 3 lety +11

    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!

  • @Sketchy144
    @Sketchy144 Před 3 lety +40

    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.

    • @giorgosotuposapotofrontist4992
      @giorgosotuposapotofrontist4992 Před 3 lety +1

      Thank you so much i have been trying to fix this for over an hour

    • @MurderApp
      @MurderApp Před 3 lety

      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.

    • @MurderApp
      @MurderApp Před 3 lety +12

      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

    • @lordawid
      @lordawid Před 3 lety +3

      @@MurderApp thank you so much bro

    • @doctorgamer0186
      @doctorgamer0186 Před 3 lety +1

      @@MurderApp Thank you very much, saved me a headache.

  • @milesmumme3611
    @milesmumme3611 Před 3 lety +48

    Me: tries to drag and drop the character controller. Unity: N O

  • @aligonia
    @aligonia Před 4 lety +24

    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.

  • @calibr0636
    @calibr0636 Před 5 lety +9

    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.

    • @alphacode5
      @alphacode5 Před 4 lety

      I know this comment is 5 months old but I'm having the same experience in a few weeks, how was it for you?

    • @wyattmeyer8703
      @wyattmeyer8703 Před 4 lety

      I mean that just means that you will understand it better than us "smart" people so you will really be the smart one

    • @skyline2601
      @skyline2601 Před 4 lety

      what is the point in downloading this?

  • @MakoRuu
    @MakoRuu Před 3 lety +83

    I didn't realize it was so complicated to get a character to move.

  • @MrLuchs
    @MrLuchs Před 3 lety +3

    Thank you! This solved so many problems in my project

    • @epfstudio
      @epfstudio Před 3 lety +2

      Oh MrLuchs auch hier xD

    • @vaney2657
      @vaney2657 Před 2 lety

      bei mir funktionirt der bewegungs code nich

  • @heisocean344
    @heisocean344 Před 4 lety +31

    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

    • @ParkMyFreak
      @ParkMyFreak Před 4 lety +1

      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?

    • @scratchtutorials1068
      @scratchtutorials1068 Před 4 lety +1

      Bro you helped me

    • @casualtea7973
      @casualtea7973 Před 4 lety

      very very helpful thank you

    • @azazel460
      @azazel460 Před 3 lety +2

      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

    • @Pralyth
      @Pralyth Před 3 lety

      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.

  • @stoan5776
    @stoan5776 Před 6 lety +231

    Yes we want to see animation!! And wallsliding in 2d!!

    • @chariouibouchaib4416
      @chariouibouchaib4416 Před 6 lety +3

      yes , that's what we want :))

    • @UBassBoostHD
      @UBassBoostHD Před 6 lety +1

      That would be great!

    • @lilal87
      @lilal87 Před 6 lety +1

      Please

    • @sink899
      @sink899 Před 6 lety +2

      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.

    • @Maik8885
      @Maik8885 Před 6 lety

      Yeah, *YAY!

  • @Adam-rp7wz
    @Adam-rp7wz Před 3 lety +3

    If your using basic shapes turn on air control to move

    • @melon5345
      @melon5345 Před 3 lety

      Dude thank you this solved my issue. Could you explain why this fixes it? I set up my colliders exactly like he did

    • @Adam-rp7wz
      @Adam-rp7wz Před 3 lety

      @@melon5345 if your character is shaped weirdly and has different colliders than it should it might clip into the ground

  • @tejanbah3216
    @tejanbah3216 Před 3 lety +18

    when you find that you are unable to crouch go to "Character Controller 2D" then go to line 67 change (!Crouch)
    to (Crouch)

    • @anthonyrudasics570
      @anthonyrudasics570 Před 3 lety +2

      Thanks, that worked!

    • @arhziz
      @arhziz Před 3 lety +2

      thanks

    • @direpants4646
      @direpants4646 Před 3 lety

      you're very attractive

    • @plagx3428
      @plagx3428 Před 2 lety

      Thx. My box collider was just turning on and off in infinit loop- this (!Crouch) was the problem:)

  • @sra2907
    @sra2907 Před 4 lety +17

    We don't want the player to walk ontop of himself hahaha, made my day!

  • @cahtoah
    @cahtoah Před 4 lety +60

    ANSWER: "I CAN'T JUMP"
    1. Your ground check is higher than your legs hitbox. (In this case the circle hitbox) If your hitbox is raising your groundcheck above the ground, it wont be able to read that you are touching the ground.
    2. This one got me for literally 30-40 hours. (Sad, I know.) He has an "Obstacle" layer under the "What is ground" option for the CharacterController script that you have to make yourself.
    To make it look at the top right of your screen and you will see a "Layer" dropdown that is set to Default. Click it and make a new layer. Make it in one of the available spots and name it something like groundLayer or Obstacle. Then you can change the "What is ground" setting and make sure the one you added is checked.

    • @tiagoamador6607
      @tiagoamador6607 Před 4 lety +1

      YOU SAVED ME!!!!! I'm developing a game for a school project, and I'm stuck with this like 2 months. I'm a complete beginner, thats why I'm here. Thank you so much.

    • @silkebork6122
      @silkebork6122 Před 4 lety +1

      Help!
      I followed the Tutorial to 16:30 and I Had No Errors in Visual Studio. In Unity, Ihad the Error ArgumenExeption: Input Axis horizontal is not setup. I cant move or jump. What can I do? I Just startest programming.

    • @waldemarSVK
      @waldemarSVK Před 4 lety +2

      @@silkebork6122 It's case sensitive so you probably have only the "h" lowercase ...change that to "Horizontal" as it is in the Input manager

    • @meomaybe0104
      @meomaybe0104 Před 4 lety +2

      uh the "obstacle" you created contains nothing in it so idont think its the problem here
      and I STILL CANT'T JUMP

    • @aaush_
      @aaush_ Před 4 lety

      elaborate option 2 pls @Cahtoah

  • @johnbrown7373
    @johnbrown7373 Před 3 lety +3

    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.

    • @FinnAHuman
      @FinnAHuman Před 3 lety

      @G19tube Gkouk You need to create it. Go Layer -> Add layer... and name any User Layer(in video it is 8) as Player

    • @FinnAHuman
      @FinnAHuman Před 3 lety

      @G19tube Gkouk save your script

  • @henrykuld
    @henrykuld Před 2 lety

    Just went to Uni to study game design and development and that video have already helped me out in my first project.

  • @billdosk
    @billdosk Před 4 lety +33

    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

    • @RHCIPHER
      @RHCIPHER Před 3 lety

      i found the problem with jumping animation should put exit time to 1

    • @surylanramadu7826
      @surylanramadu7826 Před 3 lety

      @@RHCIPHER No that just loops it if the animation doesnt fully play: (

    • @loni4891
      @loni4891 Před 3 lety

      @@cloudythb did you put a box collider 2D on your platform ?

    • @loni4891
      @loni4891 Před 3 lety

      nvm it's on a player controller then uuuuuh

    • @sameerop7860
      @sameerop7860 Před 3 lety

      player layer is not there when we choose what is ground please help

  • @rohanpatel2608
    @rohanpatel2608 Před 6 lety +53

    A wall grab and wall jump tutorial would be great!!!

    • @xavmanisdabestest
      @xavmanisdabestest Před 6 lety +1

      Quill 18 has an amazing character controller that includes that if you don't want to wait for brackys to make one :)

    • @Natsumi170
      @Natsumi170 Před 6 lety +7

      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.

    • @Metacious
      @Metacious Před 6 lety +1

      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

    • @kahlialynch2504
      @kahlialynch2504 Před 6 lety

      Or you can add a physics material and bump the friction up to one

  • @APJustAGamer
    @APJustAGamer Před 2 měsíci

    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

  • @chriswhitmire4167
    @chriswhitmire4167 Před 3 lety +2

    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.

  • @Kiki-deLucio
    @Kiki-deLucio Před 5 lety +4

    This worked, thank you so much!! I've struggled with the problem of movement for 3 days now

  • @stellarestuary589
    @stellarestuary589 Před 5 lety +6

    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!

    • @HannahSmeal
      @HannahSmeal Před 5 lety +1

      Hahaha a few hours of scratching your head

    • @thedruid1105
      @thedruid1105 Před 5 lety

      @stellarestuary thanks to you i didn't have to spend more than 30 min :P

    • @babitadeboer6338
      @babitadeboer6338 Před 5 lety

      yes like me . scratched my head into oblivion. Thank you!!!

  • @func_e
    @func_e Před 2 lety +2

    Miss these guys....

  • @andrewyannik7136
    @andrewyannik7136 Před 3 lety +5

    Thanks Brackeys, my character finally moves. Thanks for making this tutorial, it really helped .👍

  • @TimTraV
    @TimTraV Před 6 lety +37

    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.

  • @santimontano8712
    @santimontano8712 Před 4 lety +4

    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

  • @khudkhed2955
    @khudkhed2955 Před 3 lety +3

    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"

  • @GDPro219
    @GDPro219 Před 9 měsíci

    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.

  • @squrdyt5734
    @squrdyt5734 Před 5 lety +99

    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.

    • @CringeYoutubeName69
      @CringeYoutubeName69 Před 5 lety +6

      bro no matter when they do it it wont change the fun factor

    • @kilianlang3316
      @kilianlang3316 Před 5 lety +27

      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....

    • @hyperpengu8722
      @hyperpengu8722 Před 5 lety +1

      @@kilianlang3316 this is a joke right? r/wooosh? now IM confused :/

    • @tobihudiat
      @tobihudiat Před 5 lety

      C++ and C# is not the same (I've learned C++ but I need for Unity C# :/)

    • @NuclearHonzo
      @NuclearHonzo Před 5 lety +1

      @@kilianlang3316 Then you shouldn't start off with this video then...

  • @ethanholter
    @ethanholter Před 5 lety +72

    How to create movement in unity
    Step 1: Copy paste someone else's code
    Step 2: Enjoy

    • @galaxyguy4247
      @galaxyguy4247 Před 5 lety

      i dislike your comment

    • @charlesspurjeon
      @charlesspurjeon Před 4 lety +1

      After a while....
      Step 3: Realize that i should've written my own code (because of the errors)

  • @MitazasAlways
    @MitazasAlways Před 2 lety

    I came back Brackeys for seeing your videos after 1 year!!

  • @mccloudtwitch8786
    @mccloudtwitch8786 Před 3 lety +1

    I didn't want to click on this video but it was better then the other videos I saw so I had to sub

  • @nemanjaschweis1756
    @nemanjaschweis1756 Před 5 lety +5

    I'm coming from 2029 and i can tell you Brackeys is still one of the best teachers

    • @arokumi5811
      @arokumi5811 Před 5 lety

      all i care about is that barca is awful

    • @AlphaToast27
      @AlphaToast27 Před 4 lety

      then why the fuck doesn’t this work

  • @rodzme361
    @rodzme361 Před 4 lety +7

    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!

  • @suryamdg
    @suryamdg Před 2 lety +2

    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

  • @pikapikalis
    @pikapikalis Před 2 lety +3

    17:58. Don’t mind me I’m just marking my spot

  • @strogarth6752
    @strogarth6752 Před 4 lety +12

    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.

    • @hippotato4863
      @hippotato4863 Před 4 lety

      Thank you so much, you actually saved me!!!!!! I was so confused

    • @lorenzsubaan4288
      @lorenzsubaan4288 Před 4 lety

      crouch is not working

    • @Teiske
      @Teiske Před 4 lety

      @Huran How did you solve iy then?

    • @atty1337
      @atty1337 Před 3 lety

      wow thank you so much :D

  • @ziggykac
    @ziggykac Před 5 lety +3

    If your player is always crouching, but you want the player to automatically crouch when it's under something, dont change the controller script to if (!crouch). Make a "player" layer and uncheck it from the "What is Ground" thing and then choose that layer for the player.

  • @blockay4392
    @blockay4392 Před 3 lety +99

    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!

    • @derboyderg1467
      @derboyderg1467 Před 3 lety +3

      I can 100% relate to that

    • @wssoup
      @wssoup Před 3 lety +4

      Update to a newer version, unity 2020.2 has no errors.

    • @sameerop7860
      @sameerop7860 Před 3 lety +1

      player layer is not there when we choose what is ground please help

    • @polly5229
      @polly5229 Před 3 lety

      @@sameerop7860 you have to create the layer yourself i assume. Theres an ADD LAYER setting when you choose a layer.

    • @sameerop7860
      @sameerop7860 Před 3 lety

      @@polly5229 thanks for your help I figured it out now

  • @themaydayman
    @themaydayman Před 3 lety +1

    I love it. Making a platformer where you control a riding sheep and didn't have a script to use. This really helped!

    • @GilbertHernandez-eg8dx
      @GilbertHernandez-eg8dx Před 9 měsíci

      that game sounds fun, did you made it?

    • @themaydayman
      @themaydayman Před 9 měsíci

      @@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

  • @andrewvaughan3825
    @andrewvaughan3825 Před 5 lety +43

    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
      @Affe71 Před 5 lety +2

      " 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.

    • @toystoryjohn8457
      @toystoryjohn8457 Před 5 lety +2

      @@Affe71 took me a solid few minutes to figure out, i put the box collider on the wrong thing shit happens

    • @Affe71
      @Affe71 Před 5 lety +1

      @@toystoryjohn8457 box colliders work but i would use tile map colliders if all you want is for the player to walk on tiles.

    • @toystoryjohn8457
      @toystoryjohn8457 Před 5 lety

      @@Affe71 i tried using those but it wasnt working with a sloped ground right

    • @RILCOMusic
      @RILCOMusic Před 5 lety +8

      @@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.

  • @jacobWhite517
    @jacobWhite517 Před 4 lety +6

    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

    • @giventeacher5653
      @giventeacher5653 Před 4 lety +1

      Still doesn't work, idk

    • @greeny.69
      @greeny.69 Před 4 lety

      @@giventeacher5653 same problem

    • @eco8073
      @eco8073 Před 4 lety

      You have to Drag your player to "controller" slot in PlayerMovement in unity

    • @Minic3
      @Minic3 Před 3 lety

      Thanks

  • @emmygraphicss
    @emmygraphicss Před 2 lety +3

    For anyone else having trouble with the jump, make sure your ground Layer is set to something other than default

  • @user-oi6nc2bv1f
    @user-oi6nc2bv1f Před měsícem

    I know I'm too late for this video, but your explanation helped me to solve double jump problem!!! So thx ^^

    • @bluecargirl2905
      @bluecargirl2905 Před měsícem

      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.

  • @kylejj1998
    @kylejj1998 Před 4 lety +2

    I am not verry good at computering, but i think im gonna learn a lot from you. Thanks! You keep it straight and simple, so people with no experience like me can understand it.

  • @neopiru7904
    @neopiru7904 Před 6 lety +290

    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

    • @matthewbevilacqua8605
      @matthewbevilacqua8605 Před 5 lety +2

      I tried learning but it's so boring just do what the tutorial says

    • @LBZDreamer
      @LBZDreamer Před 5 lety +1

      that's how it was when I started.

    • @DrewSunn
      @DrewSunn Před 5 lety +17

      @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.

    • @matthewbevilacqua8605
      @matthewbevilacqua8605 Před 5 lety

      @Scar Im doing it as a hobby m8 I'll learn l8er

    • @matthewbevilacqua8605
      @matthewbevilacqua8605 Před 5 lety

      @Scar You're making me think I shouldn't become a game dev then...

  • @xenn6842
    @xenn6842 Před 3 lety +2

    how do i download this (PLEASE HELP)

  • @Ness_Dreemurr
    @Ness_Dreemurr Před 3 lety +3

    dude, you are awesome! as a beginner, these vids are SUPER helpful!

  • @creeperbc0254
    @creeperbc0254 Před 3 lety +6

    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.

  • @nikoala2921
    @nikoala2921 Před 3 lety +7

    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!!!

    • @tanomations3300
      @tanomations3300 Před 3 lety

      thanks so much i overlook alot

    • @fazilllay
      @fazilllay Před 3 lety +2

      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!

    • @UC-Doctor
      @UC-Doctor Před 3 lety

      @@fazilllay WE LIKE U

  • @DEFYED
    @DEFYED Před 3 lety +1

    Not sure what is going on but I can't seem to get the crouch collider to work properly. If something is above, the collider just turns itself back on and gets the player stuck in walls '-_-

    • @DEFYED
      @DEFYED Před 3 lety

      fixed it... by not changing his code. line 67 !crouch is actually *correct* as it checks to see if you are trying to stand up (crouch = false) - if crouch is true, then you aren't trying to stand up so it just re-enables the collider which it shouldn't do.

    • @noxx4001
      @noxx4001 Před 3 lety

      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

  • @Alamiri757
    @Alamiri757 Před 3 lety +3

    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!

  • @DANKAF
    @DANKAF Před 5 lety +4

    and if u did:
    if (Input(Getbuttondown(''Jump''))
    {
    jump = True
    } else if (Input(Getbuttonup(''Jump''))
    {
    jump = False
    }
    the character would jump until buttonup??

    • @_mementox
      @_mementox Před 5 lety

      and if you removed the jump = false at the end, yes

  • @animadoarts5123
    @animadoarts5123 Před 5 lety +3

    please make a full 2d player movement video. Where we can learn how to change direction of player while moving.

  • @codyomeara
    @codyomeara Před 3 lety +5

    I dont understand, Its like I missed a video before this but cant find it... My character wont move. If I press "A" and "D" my character flips like it should but that about it.

  • @becauseimtobyfilms3559
    @becauseimtobyfilms3559 Před 3 lety +1

    Brackets you are the best ever love your channel so much you actually explain it instead of telling us to do it

  • @Arnmazing23
    @Arnmazing23 Před 5 lety +4

    You should do a series of teaching the Unity documentation/API.

  • @bymetal214
    @bymetal214 Před 4 lety +6

    For those who can't jump:
    Move the Groundcheck (of your player) a bit more down. It fixed my player's jump.

  • @yoyoboy3665
    @yoyoboy3665 Před 2 lety +2

    for those who cant go up a slant add a polygon collider insted of a box collider

  • @cocoad1034
    @cocoad1034 Před 3 lety +5

    please help when i try to move my character, it just says, NullReferenceException = reference not set to object
    Edit: i realised that i hadnt dragged controller into the slot so ye

  • @maximusTVfull
    @maximusTVfull Před 4 lety +5

    How I can stick to slopes? Right now my player sliding down from any slopes. I need to add something to CharacterController2D class I guess.

  • @HatemAlfarra
    @HatemAlfarra Před 4 lety +4

    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.

    • @HatemAlfarra
      @HatemAlfarra Před 4 lety +1

      It took me days to identify my mistake. I hope this helps

    • @DerMberger
      @DerMberger Před 3 lety

      Oh my god, thank you! I've been looking for days too for this now haha...

  • @costachristos9183
    @costachristos9183 Před 3 lety

    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!

  • @PabTSM-OfficialChannel
    @PabTSM-OfficialChannel Před 3 lety +12

    So now we wanna do thi-
    (shows dramatic trailer)
    *BRUH THAT IS SO HARD*

    • @B8Code
      @B8Code Před 3 lety

      czcams.com/video/YzCF3zbfUE0/video.html

  • @mint3912
    @mint3912 Před 3 lety +5

    CZcamsr: *makes a game making tutorial*
    Game Monkey ad: Is For Me???

  • @Intilla
    @Intilla Před 2 lety +3

    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

    • @littledude52
      @littledude52 Před 2 lety +1

      14 hours after you commented you already helped me lmao thanks

    • @Intilla
      @Intilla Před 2 lety

      @@littledude52 Bahahha that's amazing!! xD Glad I could help

  • @shwetaSharma-vf4hh
    @shwetaSharma-vf4hh Před 2 lety +2

    If your character fall on ground
    Go to player rigidbody 2d
    In constraints check freeze rotation z
    This may fix your problem

  • @weikee7610
    @weikee7610 Před 3 lety +4

    For Jumping Animation Solution:
    On CharacterController2D script
    In the statement "if (m_Grounded && Jump)" it returns this: "m_Grounded = false"
    this should be changed to "m_Grounded = true"

    • @GUYAV
      @GUYAV Před 2 lety +2

      THANK YOU! I spent a whole hour trying to fix it

    • @weikee7610
      @weikee7610 Před 2 lety +1

      @@GUYAV you are welcome, me too 😂

    • @Phoenix-0455
      @Phoenix-0455 Před 2 lety

      @@weikee7610 its... the same thing. If you don't specify it will default to true :)

    • @weikee7610
      @weikee7610 Před 2 lety

      @@Phoenix-0455 got the bug there 😄

    • @waritphankrawee1356
      @waritphankrawee1356 Před rokem

      OMG thankyou so much. i was finding this solutions everywhere

  • @paologinefra4980
    @paologinefra4980 Před 5 lety +11

    I've followwed the tuotorial but my sprite dosen't jump and I thing that's a "character 2d contoller"'s problem

    • @yashsoni9935
      @yashsoni9935 Před 4 lety

      Did you get this figured out, I have the same problem.

    • @AkHolic0
      @AkHolic0 Před 4 lety

      @@yashsoni9935 You have to make sure your character is grounded, which means you have to add 2D box Collider to the ground where he is standing.

    • @atra1068
      @atra1068 Před 4 lety

      @@AkHolic0 i did that but mine does walk or jump i think its because of controller is to bone but i dont know how to change it

    • @ybkinfo12
      @ybkinfo12 Před 4 lety

      move ground check down under character

  • @jovannovakovic5975
    @jovannovakovic5975 Před 6 lety +642

    Coding your own games is easier than you think

    • @thepotatoduke1948
      @thepotatoduke1948 Před 6 lety +206

      Jovan Novakovic you know, YoU sHouLd takE ThiS onLinE UniTY cOURse oN UDeMY.

    • @antopilo7418
      @antopilo7418 Před 6 lety +48

      IT STARTED PLAYING AS I WAS READING YOUR COMMENT.

    • @ChadRockwell
      @ChadRockwell Před 6 lety +29

      But have you heard about skillshare?

    • @tarsierontherun
      @tarsierontherun Před 6 lety +24

      Hello, this is code monkeyand

    • @proccessingunit2337
      @proccessingunit2337 Před 6 lety +30

      Sometimes I consider getting Adblock to save my sanity, but then I remember that the ads support the users I watch

  • @wxlked_
    @wxlked_ Před rokem +1

    i wrote everything write for the jump, but whenever i press spacebar it doesn't jump? how do i fix this

  • @Robin_H.I
    @Robin_H.I Před rokem +2

    i tried to use this and i could not get the code to work sadly any know fix or so?