2D Player Movement In Unity

Поділитися
Вставка
  • Опубліковано 5 лют 2025
  • Learn how to move and jump in Unity!
    Source code: gist.github.co...
    SOCIAL
    Discord: / discord
    itch.io: bendux.itch.io/
    Twitter: / bendux_studios
    SUPPORT
    Buy Me a Coffee: www.buymeacoff...
    MUSIC
    By the Fireplace by TrackTribe
    Home for the Holidays by TrackTribe

КОМЕНТАРІ • 2,1 тис.

  • @fluffystuff
    @fluffystuff 2 роки тому +113

    as a complete beginner. I did not understand this video very well but after a few weeks of messing around in unity and i can finally understand what is in this video

    • @Externium
      @Externium 2 роки тому +10

      Yeah what in the world is going on here ._.

    • @Skitozzz
      @Skitozzz Рік тому +1

      @@Externium :)

  • @ErraticPulse
    @ErraticPulse 2 роки тому +141

    Fun Fact, if u look at some of the areas on the script window you will notice that the language is in german

  • @guyinaraincoat4292
    @guyinaraincoat4292 Рік тому +37

    This tutorial was very helpful by showing the whole process of making the script that made the character move, Thank you!

  • @The_Gronne
    @The_Gronne 2 роки тому +126

    This is probably the best programming tutorial I've ever seen. Extremely easy and to the point. And for someone who's done this multiple times in the past, but simply don't want to type it all out again, linking the source code makes everything so much easier.

  • @schauerv
    @schauerv 2 роки тому +66

    God tier tutorial, finally something that is short and works great instead of an 18 min video that bugs out!

  • @deilruchi
    @deilruchi Рік тому +102

    If your character is moving left and right but doesn't jump after finishing tutorial you might have missed the point where he moves Ground Check object early in the video closer to players feet and ground. 🎉

    • @joshpreston4957
      @joshpreston4957 Рік тому +8

      Been working on this issue for literally weeks, bless you wise internet stranger!

    • @deilruchi
      @deilruchi Рік тому +1

      @@joshpreston4957 Glad it helped you, because it took me a while as well.

    • @mariazia221
      @mariazia221 Рік тому +1

      where

    • @deilruchi
      @deilruchi Рік тому

      @@mariazia221 ua-cam.com/video/K1xZ-rycYY8/v-deo.html

    • @Garfield_Minecraft
      @Garfield_Minecraft Рік тому

      OMG thank you god it's been 3 hours just sitting here what went wrong

  • @leonzuendel123
    @leonzuendel123 10 місяців тому +81

    The video would be a lot better if you'd actually explain WHY you do certain things instead of just telling us THAT you're doing it. Could have just provided the source code without a video at this point (for the most parts).

    • @ericantone8709
      @ericantone8709 6 місяців тому +17

      this is the biggest mistake online unity tutorials make. they never explain why things work the way they do.

    • @magnusman
      @magnusman 6 місяців тому +4

      Exactly!

    • @marik996
      @marik996 5 місяців тому +3

      I agree

    • @ghostreaper8876
      @ghostreaper8876 4 місяці тому +3

      Whomp
      Whomp jk I agree

    • @childtaker318
      @childtaker318 15 днів тому +4

      I saw this comment before seeing the entirety of the video and I fought "what do they mean everything here is self explanatory." now the video is finished I entirely understand what you mean.

  • @monkeypwners
    @monkeypwners Рік тому +11

    Very nice video, easy to follow! I just feel like you go over some stuff without explanation, which can make it difficult to understand why we do what we do, like Collision Detection, Sleeping mode and interpolate. I have no idea what it means, but I just do as you say and it works :) Great video overall tho! Big props!

  • @FireGloves
    @FireGloves Рік тому +44

    If anyone's wondering why they can't jump, the "jump" key is set to space by default. To change it to something else, here's the code.
    if (Input.GetKeyDown(KeyCode.UpArrow) && IsGrounded())
    {
    rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
    }
    if (Input.GetKeyUp(KeyCode.UpArrow) && rb.velocity.y > 0f)
    {
    rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
    }

    • @BIGBLACKHAWK123
      @BIGBLACKHAWK123 Рік тому +5

      It doesn’t work even if I press space though 🫤

    • @dalegacy2877
      @dalegacy2877 Рік тому

      @@BIGBLACKHAWK123You definitely done something wrong then. I had the same issue until I linked all the objects. Try watching the video multiple times to understand what is actually going on rather than saying it doesn't work. :)

    • @zanahtile6276
      @zanahtile6276 Рік тому +4

      Check if your Ground Check is actually "grounded". If you create it first, it places the object in the middle of the player, this causes it to never touch ground. And results in failing the ground check and blocking you from jumping. Move it lower on the player.@@BIGBLACKHAWK123

    • @Noone-tw8
      @Noone-tw8 Рік тому

      omg thank you I haven't knew that.

    • @TheGreyCat1026
      @TheGreyCat1026 Рік тому

      that was the problem, thanks!@@zanahtile6276

  • @mitchelllockyer7541
    @mitchelllockyer7541 Рік тому +52

    bippity boopity your code is now my property

  • @c0rse198
    @c0rse198 Рік тому +4

    After 3 hours of attempting to figure out why I wasn't able to jump, I found that you need to assign your keys to the "Jump" input in input settings. While horizontal is pre-set, jump is left blank and this left me absolutely baffled until I figured it out.

  • @lemason5981
    @lemason5981 Рік тому +6

    that ground checking system is simplistic brilliance, I was stuck for hours trying to think of that and in this moment i am hoping that you're a wizard and it's not just some super simplistic thing everyone has been doing for ages except me

    • @bendux
      @bendux  Рік тому +2

      Haha, I'm definitely not a wizard.

    • @NewSunnahAcquired
      @NewSunnahAcquired 8 місяців тому +1

      @@bendux thats exactly what a wizard would say

  • @its_a_gamer5279
    @its_a_gamer5279 2 роки тому +10

    For everyone that struggles with the player falling through the ground,
    Make sure that your ground is not imported from a file but made in the 'Hierarchy'. (if its not imported its grey in the hierarchy otherwise its blue)
    Good luck!

    • @bendux
      @bendux  2 роки тому

      Thank you for sharing!

    • @its_a_gamer5279
      @its_a_gamer5279 2 роки тому

      @@bendux np!

    • @wogs2k
      @wogs2k 2 роки тому

      I did this and it still doesn't work

    • @bendux
      @bendux  2 роки тому

      @@wogs2k Join our Discord server, and let's solve your problem together!

    • @sirnoodle2004
      @sirnoodle2004 2 роки тому

      @@wogs2k Also make sure that on both the BoxCollider2D of the player and the platforms, the box "Is Trigger" is not ticked

  • @yugnatata
    @yugnatata 10 місяців тому +1

    Thank you! I spent over 10 hours trying to do this and you showed me how to in 5 minutes, it's perfect! Just had to be a little careful as you didn't say out loud everything you were saying, but it's otherwise an amazing video, and still up to date! Thanks again!

  • @GD-Monkey
    @GD-Monkey 7 місяців тому +2

    This is the only tutorial where I get good physics for the player, thanks so much :)

  • @enderpigerdragon3589
    @enderpigerdragon3589 Рік тому +9

    Thanks for the awesome 2D movement in Unity tutorial! Super helpful! 👍

  • @Skylar.H93
    @Skylar.H93 Рік тому +27

    Amazing, I was able to figure it out from the video with only like 2 errors that were extremely easy to solve. Superb video!
    Now I just gotta figure out how to make magic fist attacks with effects, determine a combo system, and design and figure out how to link side profiles to the player sprite with walking animations.

    • @bendux
      @bendux  Рік тому +5

      I'm glad I could help. Good luck!

    • @LucaThePupineer
      @LucaThePupineer Рік тому

      HOW THIS FEELS IMPOSSIBLE

  • @historyjunior
    @historyjunior Рік тому +4

    This is an amazing tutorial! Thank you so much, I really loved this!

  • @kidthelett
    @kidthelett 10 місяців тому +1

    Beautiful. Kinda funny I thought the jump didn't work cause i was pressing w or the up button, but then i realized it was space

  • @1ts_Leen0
    @1ts_Leen0 7 місяців тому

    I struggled with the built-in input manager. No matter what I did it seemed to apply some form of deceleration/acceleration when I moved the player. So instead, I did something similar to you in this video and that fixed it. Nice and snappy movement, just as you'd expect in a 2D game.

  • @Arrzee.
    @Arrzee. Рік тому +31

    Here is the script for those who need it
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerMovement : MonoBehaviour
    {
    private float horizontal;
    private float speed = 0f;
    private float jumpingPower = 16f;
    private bool isFacingRight = true;
    [SerializeField] private Rigidbody2D rb;
    [SerializeField] private Transform groundCheck;
    [SerializeField] private LayerMask groundLayer;
    // Start is called before the first frame update
    void Start()
    {
    }
    // Update is called once per frame
    void Update()
    {
    horizontal = Input.GetAxisRaw("Horizontal");
    if (Input.GetButtonDown("Jump") && IsGrounded())
    {
    rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
    }
    if (Input.GetButtonUp("Jump") && rb.velocity.y > 0f)
    {
    rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
    }
    Flip();
    }
    private void FixedUpdate()
    {
    rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
    }
    private bool IsGrounded()
    {
    return Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
    }
    private void Flip()
    {
    if ((isFacingRight && horizontal < 0f) || (!isFacingRight && horizontal > 0f))
    {
    isFacingRight = !isFacingRight;
    Vector3 localScale = transform.localScale;
    localScale.x *= -1f;
    transform.localScale = localScale;
    }
    }
    }

    • @wizard7317
      @wizard7317 Рік тому +1

      yo, my serialized fields arent showing up in my unity project and i was wondering if you could help

    • @noona7701
      @noona7701 Рік тому

      @@wizard7317 did u save the script in vs before going back to unity?

    • @furyz0339
      @furyz0339 Рік тому +1

      this script gives me no movements :c i turn left and right but cannot move

    • @noona7701
      @noona7701 Рік тому +3

      @@furyz0339 you have to change the speed in vscode to 8 (in the comment it is set to 0)

    • @furyz0339
      @furyz0339 Рік тому

      thank youuu @@noona7701

  • @matsu4721
    @matsu4721 3 роки тому +16

    Thanks for this awesome smooth moving video, but can you do 2d enemy ui or shooting?

    • @bendux
      @bendux  3 роки тому +3

      I've added it to my list. Thank you for the suggestion!

    • @ZephyrAnimationss
      @ZephyrAnimationss 2 роки тому +2

      @@bendux YEsssssss exactly what i wanted thanks(i want to make a shooter game cuz im new)

  • @cheezeburger7716
    @cheezeburger7716 2 роки тому +8

    Very nice tutorial, one thing that I noticed, or if I may have missed, however, is that when I go to jump, the player doesn't have a limit to how many times they can jump in the air. Is there something that I would need to type in to fix that? I noticed that wasn't established in the video, but if anyone has an idea of how to put that in it would mean a lot. I'm a beginner at coding myself, so I'm not too big on this kind of stuff.

    • @bendux
      @bendux  2 роки тому

      Would you like to show me your code on Discord?

    • @cheezeburger7716
      @cheezeburger7716 2 роки тому

      @@bendux Oh, thank you. But I actually managed to figure it out from another source. I appreciate the offer though. And what all you had shown here in the video.

    • @bendux
      @bendux  2 роки тому

      @@cheezeburger7716 I'm glad you were able to fix it.

    • @ab7299
      @ab7299 2 роки тому +1

      @@cheezeburger7716 can you tell me how you fixed it? i want to fix it too

    • @aniime4006
      @aniime4006 2 роки тому

      @@cheezeburger7716 can you tell me how you fixed it? i want to fix it too

  • @polyhedrainteractive9663
    @polyhedrainteractive9663 Рік тому +1

    This is incredible, I coded for a while but couldn't get past the basics will watch more

  • @markotafa
    @markotafa Рік тому +1

    I like people that actually put code in the despcription :)

  • @EyezCantSee
    @EyezCantSee Рік тому +13

    Hey! Just wondering, if we want to animate, what boolean or Float should i use for the transition?

  • @LilCouve
    @LilCouve 2 роки тому +3

    Thank you, this was my first time using C# and this really helped me!

  • @slayerghande7969
    @slayerghande7969 2 роки тому +5

    Yo, great work here 👏.
    Don't ever stop and you will be the new brackeys

  • @dmitriyleonov6977
    @dmitriyleonov6977 Рік тому +2

    Отлично. Я делал подобный урок от другого автора. Персонаж дёргался. А тут всё движется плавно и код выполнен здорово компактно. Настройки физического тела показал как настроить . Спасибо за урок

  • @lennystudios3.14
    @lennystudios3.14 Рік тому +1

    Love it, I personally like adding a Lerp function for some smoother acceleration and floatier physics, but that’s just my prefrance

  • @Nintendostar02
    @Nintendostar02 2 роки тому +3

    When you'll make a video about how do object follow the player (like Mario, luigi and paper mario in Mario and luigi paper jam), i'll be very happy. Great video, i resolved all my problem with 2d player movement

    • @bendux
      @bendux  2 роки тому +2

      I've added it to my list. Thank you for the suggestion!

  • @amburdo6206
    @amburdo6206 2 роки тому +5

    Thanks for the great video. I wanted to ask about one thing I'm quite confused about. It seems that you didn't program any horizontal movement keys that need to be pressed down to move, yet you still are able to move. The only key you referenced in the script was jump. How is that possible?

    • @bendux
      @bendux  2 роки тому +2

      Edit > Project Settings > Input Manager

    • @amburdo6206
      @amburdo6206 2 роки тому

      @@bendux Thanks a lot!

    • @lilili765
      @lilili765 Рік тому +1

      ​@@benduxwhat do i do in inputmanager

  • @swish_tm6660
    @swish_tm6660 2 роки тому +2

    My face when i don’t understand 99.9999% of the code 5:33

    • @bendux
      @bendux  2 роки тому

      I definitely want to make more beginner-friendly videos in the future.

  • @-._122
    @-._122 Рік тому +1

    @bendux THIS IS THE BEST TUTORIAL EVER!!! I CAN MOVE AND JUMP btw you just earned a sub

    • @bendux
      @bendux  Рік тому

      Thank you!

    • @-._122
      @-._122 Рік тому

      @@bendux no problem

  • @nagisa1578
    @nagisa1578 2 роки тому +2

    Man thx, did know / thought you cloud just change the velocity in script. Makes everything soooo much easyer and I dont have to fiddle around with AddForce etc. Thank you again man.

  • @vrsuhfx
    @vrsuhfx 2 роки тому +3

    Hey! Quick question, how exactly would i make the run/walk a method if possible? Just so that I have a place to add in my audio, dust particles, etc. Cuz I'm new to this whole thing haha

    • @bendux
      @bendux  2 роки тому +3

      The answer to your question goes beyond the scope of a UA-cam comment, but I'd still like to help you. Join our Discord server, and let's solve your problem together!

  • @feddyfadbear7985
    @feddyfadbear7985 2 роки тому +4

    hey, great video, everything is working fine but im jumping WAY too high, how can i decrease the jump power?

    • @bendux
      @bendux  2 роки тому

      Decrease the jumping power at the top of the script.

    • @BHArv3y
      @BHArv3y 2 роки тому +3

      you can change the value in the script from "private float jumpingPower" to "public float jumpingPower" and this will allow you to directly adjust the power in unity rather than opening the script! :D good luck!

    • @gumball5372
      @gumball5372 7 місяців тому

      @@bendux didnt do anything, is there another fix?

    • @bendux
      @bendux  7 місяців тому +1

      @@gumball5372 Increase the gravity scale of your player's Rigidbody 2D component.

    • @gumball5372
      @gumball5372 7 місяців тому

      @@bendux i found the fix, i tried this but it didnt work. I have no clue what the problem was but it works now

  • @W5AKC
    @W5AKC 2 роки тому +4

    Very nice and simple.

  • @Apleker
    @Apleker Рік тому +1

    Hippity Hoppity Your Code Is Now My Property - "Apleker"

  • @Think_Stream
    @Think_Stream Рік тому +1

    thanks a lot bro i went to many videos just for this even brackys tutorial didnt work
    and i tried this love you bro

    • @iAmStanee
      @iAmStanee Рік тому

      Brackys tutorial is where all the souls go😂😂

    • @gumball5372
      @gumball5372 7 місяців тому

      @@iAmStanee its just really outdated

  • @alexwellman6605
    @alexwellman6605 2 роки тому +14

    I have a problem with the movement, I added the no friction material to two objects, but after they collide, they start getting stuck on the floor, even after moving and jumping
    The floor uses tilemap colliders, if that helps
    Edit: probably solved, I used a composite collider too

    • @bendux
      @bendux  2 роки тому +7

      Add a Composite Collider 2D component to your tilemap.

    • @alexwellman6605
      @alexwellman6605 2 роки тому +5

      @@bendux thank you so much

  • @frogwav
    @frogwav 2 роки тому +4

    You explained this well. also it works. thanks!

  • @krzaczastyyt6547
    @krzaczastyyt6547 3 роки тому +3

    Your tutorials are the best i gona make a game with those

  • @ThisIsStoneGD
    @ThisIsStoneGD 10 місяців тому +1

    I want my cube when the cube is jumping while moving to the right, the cube will jump and rotate 90 degrees to the right as well and there should be a kind of animation and not just instantly changed to 90 degrees.
    Edit: just like in Geometry Dash

  • @iamkennegee
    @iamkennegee 4 місяці тому

    I could use some help regarding slopes. Much appreciated for the easy to follow tutorials!

  • @EmirDuman1
    @EmirDuman1 Рік тому +5

    i can't jump

    • @finngrainger349
      @finngrainger349 Рік тому

      neither, left and right works just no jump

    • @wayvoedorado71
      @wayvoedorado71 Рік тому

      have any of you found a solution yet? It looks like it's a common problem.

    • @finngrainger349
      @finngrainger349 Рік тому +1

      yes, my problem might be different to yours but I solved it by moving the 'ground check' to the position of the bottom of the player as I forgot to move it as said at 1:17@@wayvoedorado71

    • @wayvoedorado71
      @wayvoedorado71 Рік тому

      @@finngrainger349 that wasn't my problem, but you encouraged me to look into it and my problem was that I forgot to change the platform layer to ground so thank you

    • @bendux
      @bendux  11 місяців тому +1

      You probably skipped one or two important steps in the tutorial.

  • @RichardBarnes0
    @RichardBarnes0 3 роки тому +12

    The old input system is not worth using anymore.

  • @VonMoosHarrison
    @VonMoosHarrison Рік тому +8

    Literaly the most difficult to understand tutorial

  • @Boogie-wi7hd
    @Boogie-wi7hd Рік тому +2

    This tutorial was to easy to be true like how does he do so much with so less code. And not to mention its so easy to read.

  • @gameormusic2360
    @gameormusic2360 Рік тому

    bro is definitely not a beginner, Very helpful video and thank you

  • @foo3268
    @foo3268 2 роки тому +1

    underrated channel, hopefully unity notices you someday

  • @yumura137
    @yumura137 Рік тому

    very simple yet satisfying and fun movement, straight to the point video, simply one of best on youtbe

  • @Xofol
    @Xofol Рік тому

    Hey if you dont want your player to be stuck on walls when applying the horizontal force, use the CharacterController component instead!

    • @bendux
      @bendux  8 місяців тому

      Create a Physics Material 2D, set the friction to zero, and add it to your player's Rigidbody 2D component.

  • @dangngocthinhank18hcm
    @dangngocthinhank18hcm 22 дні тому

    Note: YOU NEED TO CREATE A BOX COLLIDER 2D ON TILES to stop character from falling as well

  • @JohnKirk-eb6nk
    @JohnKirk-eb6nk 2 роки тому

    I have watched tons of tutorials, best one yet

  • @B-r4c-is-100P
    @B-r4c-is-100P Рік тому +1

    my player wont stop falling through the damn ground

    • @bendux
      @bendux  11 місяців тому

      If you want two game objects to collide with each other, both game objects require a collider.

    • @kibookamc
      @kibookamc 3 місяці тому

      bro add a box collider, like you did with the player

  • @Jamal38852
    @Jamal38852 2 роки тому +1

    You literally saved me by making this video, earned a sub

  • @beepboop2851
    @beepboop2851 Рік тому +1

    Btw if u are having problems with the rub, ground check and ground layer not appearing then just copy and paste the source code in the description because I had followed all the steps and it wasn’t working but when I copied it the errors got fixed

    • @bendux
      @bendux  Рік тому +1

      The source code on GitHub is the same as in the video.

    • @antoniosalazar9505
      @antoniosalazar9505 Рік тому

      Thanks, I was just looking for this.

  • @travisc8406
    @travisc8406 Рік тому

    can we just appreciate that he is still responding to comments! you're awesome!

  • @carlosalbertobatistacruz
    @carlosalbertobatistacruz Рік тому

    Nice tutorial, the SpriteRenderer Component can also be used, just get the flipX (bool) attribute, instead of using localScale -1.

  • @Tapov_
    @Tapov_ Рік тому +2

    Thanks for the tutorial! I'm a beginner and this helps alot!

  • @childtaker318
    @childtaker318 15 днів тому +1

    Can anybody help, I cant do anything upon competing it, it just says horizontal axis not set up? is it something with velocity being obsolete?

  • @Arcann_bhp
    @Arcann_bhp Рік тому

    if you get ur player to an edge of a platform it won't be able to jump bc the ground check under the player is in the middle and doesn't cover the entire size

    • @bendux
      @bendux  Рік тому

      You can adjust the radius of the ground check.

  • @KrixerVR
    @KrixerVR 11 місяців тому

    This helped me alot and I even somehow got my player to infinite jump like flappy bird. Definitally a win

    • @bendux
      @bendux  10 місяців тому

      If you want to get rid of this behavior in the future, make sure that your player and the ground are not on the same layer.

    • @KrixerVR
      @KrixerVR 10 місяців тому

      @@bendux Thx man, oh and btw I subbed to you for your awesome Unity tips!!

    • @bendux
      @bendux  10 місяців тому

      @@KrixerVR I appreciate it. Thank you!

  • @user-ve5rr9bp3n
    @user-ve5rr9bp3n 7 місяців тому

    thank you so much ,without you i would still be stuck in how to move it .
    you've got a sub

  • @KenB1206
    @KenB1206 Рік тому

    thank you so much, sir bendux! it help quite significantly

  • @DevNoob
    @DevNoob 3 роки тому

    Always good videos! 1k subs let's go!

  • @waawaaaa
    @waawaaaa 8 місяців тому

    For those wondering why you can't jump remember to change the layer of your platforms to ground, had me confused for a few minutes

  • @The_Real_Zoouro
    @The_Real_Zoouro Рік тому +1

    Jo Gleises Video Bruder :D

  • @luccabobucca
    @luccabobucca 5 місяців тому

    Thank you for making a tutorial I could follow!

  • @forforref7968
    @forforref7968 2 роки тому +1

    Help it says vector 2 and 3 is an ambiguons reference between 'UnityEngine.Vector3' and 'System.Nuerics.Vector3'

    • @bendux
      @bendux  2 роки тому +1

      Would you like to show me your code on Discord?

    • @forforref7968
      @forforref7968 2 роки тому +1

      @@bendux I've fixed the problem already but now I can't jump

    • @bendux
      @bendux  2 роки тому

      @@forforref7968 Did you position the ground check at your player's feet?

  • @koroix34
    @koroix34 Рік тому +1

    I dont have rb, ground check and ground layer after i made the code 4:57

    • @bendux
      @bendux  Рік тому

      Did you save the script?

  • @BILGI_PASA
    @BILGI_PASA 2 роки тому +1

    Thank you bendux. The video helped me so much.

  • @chrono9503
    @chrono9503 Рік тому

    Its better to use a trigger colider instead of an empty object to check for grounded so you can change the width

    • @bendux
      @bendux  Рік тому

      You can adjust the radius of the ground check.

  • @TheofficiaLval
    @TheofficiaLval Місяць тому +1

    Hey umm what coding software are you using?:)

    • @bendux
      @bendux  28 днів тому

      I use Visual Studio.

  • @eshaanb2362
    @eshaanb2362 8 місяців тому

    Thank you so much, this tutorial was very helpful!

  • @noahprocacci8931
    @noahprocacci8931 Рік тому +1

    I'm sorry but, I though I searched up "simple 2d Unity movement guid", I was was expected much easier.

  • @francheeze
    @francheeze Рік тому

    Simple, quick & elegant. Nice!

  • @era_Animates
    @era_Animates 3 дні тому

    this is perfect, with a few google searches.(if you dont understand stuff like uhh serialize field and are VERY new to programming in c# but kinda know python.(me))

  • @totti8258
    @totti8258 Місяць тому

    what a gentle jazzy ambient

  • @potato_legend127
    @potato_legend127 Рік тому +1

    Thank you for this video. It helped me a lot!!!

  • @-iip220v
    @-iip220v 6 місяців тому +1

    Great! Its work but how to make mobile buttons?

  • @MrSmashmasterk
    @MrSmashmasterk 4 місяці тому

    How did you make those straight lines in the code at 2:46?

  • @elderbug7579
    @elderbug7579 Рік тому +2

    I tried using the code but ended up only getting the error messages:
    The namespace '' already contains a definition for 'PlayerMovement'
    Type 'PlayerMovement' already defines a member called 'Update' with the same parameter types
    Type 'PlayerMovement' already defines a member called 'FixedUpdate' with the same parameter types
    Type 'PlayerMovement' already defines a member called 'IsGrounded' with the same parameter types
    Type 'PlayerMovement' already defines a member called 'Flip' with the same parameter types
    Any help would be appreciated!

    • @WRCD247
      @WRCD247 Рік тому

      Same feels bad.

    • @bendux
      @bendux  Рік тому

      Do you happen to have another class with the same name in your project?

  • @pickleman4222
    @pickleman4222 Рік тому +1

    when i attach the script component to the player, i am given the error:
    "The associated script cannot be loaded.
    please fix any compile errors and assign a valid script."
    but vscode doesn't show any compiler errors, what do i do?

    • @bendux
      @bendux  Рік тому +1

      Make sure that the class at the top of the script has the same name as the script itself.

    • @pickleman4222
      @pickleman4222 Рік тому

      @@bendux This fixed it! Thank you!

  • @walterbbg6178
    @walterbbg6178 Рік тому +1

    Good video but i have a problem, i cant jump can i know how do i fix it?

    • @bendux
      @bendux  Рік тому

      Did you position the ground check at your player's feet?

  • @blaq6467
    @blaq6467 2 роки тому +1

    It worked for a while but then just stopped "PlayerMovement' already defines a member called 'Flip' with the same parameter types"

    • @bendux
      @bendux  2 роки тому

      Would you like to show me your code on Discord?

  • @everything-editz785
    @everything-editz785 2 роки тому

    Best unity tutorial i havrme ever seen 10/10

  • @Why_you_change_the_subject
    @Why_you_change_the_subject Рік тому +1

    I managed to get my player character to jump but the character does not want to move left and right and I don't know what is causing the problem this is my first time coding in unity

    • @bendux
      @bendux  Рік тому

      Do you get any error messages?

    • @Why_you_change_the_subject
      @Why_you_change_the_subject Рік тому

      @@bendux i get no error message

    • @bendux
      @bendux  Рік тому

      @@Why_you_change_the_subject Would you like to show me your code on Discord?

  • @ErraticPulse
    @ErraticPulse 2 роки тому +1

    I have a bug where it doesnt delete the versions of itself left behind after moving

    • @bendux
      @bendux  2 роки тому +1

      It probably has something to do with your camera.

  • @DeApple_king
    @DeApple_king 2 роки тому +1

    for some reason when i press play i get stuck to the ground even tho i added 0 friction and i cant move can u help me with that??

    • @bendux
      @bendux  2 роки тому +1

      If you have a tilemap in your scene, add a Composite Collider 2D component to it.

  • @unknown4133
    @unknown4133 2 роки тому +2

    I've spent afew hours trying to find one that worked... a 5 minute simple video, that is simple and easy to understand; compared to a 30 minute jumbled video that doesnt even work... That red subscribe button is calling!! Thank you so much

  • @AidenUPVR
    @AidenUPVR 2 роки тому +1

    Okay, normally I try fixing things myself before asking, but when I saw this I knew something was wrong.
    Whenever I opened the movement script like he did at 4:54 ; but when I did, the options never showed up, instead, I got an error reading, "The associated script can not be loaded. Please fix any compile errors and assign a valid script."
    I'm new to game design, while my only other project was a website for games I found for my friends to play in our classes. ( I hope that explains why my error might make me sound like an idiot for not knowing how to fix it. )

    • @bendux
      @bendux  2 роки тому

      Make sure that the class at the top of the script has the same name as the script itself.

    • @AidenUPVR
      @AidenUPVR 2 роки тому

      Glad I got the fix so early. You're a lifesaver.
      Now to figure out how to make the player have physics with tiles. ( Moving across tiles )

    • @bendux
      @bendux  2 роки тому

      @@AidenUPVR Add a Tilemap Collider 2D component and a Composite Collider 2D component to your tilemap.

    • @AidenUPVR
      @AidenUPVR 2 роки тому

      @@bendux I got that. I'm proud of it. Even though its just a forest green box, with a few places to stand on, I'm happy with it.
      I'm trying to make a game for my friends to play.

    • @AidenUPVR
      @AidenUPVR 2 роки тому

      I also have one more thing I want to change. In the script somewhere, there's a feature that lets the player jump infinitely. Since I'm going to be making a parkour puzzle game, I really don't need players to double-jump their way to space lol.

  • @tonkads
    @tonkads Рік тому

    2:24 can someone explain why he used FixedUpdate here and not normal Update?

  • @sonckeb.8845
    @sonckeb.8845 7 місяців тому

    i changed the input of horizontal and forgot to set Jumpingpower and MoveSpeed and it fixed all thank you
    edit: changed input back again and it worked flawless dont know what my problem was :)
    and didnt know that GetAxisRaw is refered to the a and d button

  • @EvrenN35
    @EvrenN35 Місяць тому +1

    help me my guy goes left and right but he turns immediatly, example: im going right with "d" but when i pressed "a" he teleports to back and turns to left please help

    • @bendux
      @bendux  Місяць тому

      It's hard to tell what's going on without seeing your script.

  • @RelaxReisen
    @RelaxReisen Рік тому

    Danke, hat problemlos geklappt!

  • @Hollowdude15
    @Hollowdude15 Рік тому

    Unity is so cool and nice video man :]

  • @bjarnelipp5626
    @bjarnelipp5626 6 місяців тому +1

    The jumping part isnt working for me because somehow the groundcheck isnt sticking to the character..can anybody explain what to do

    • @bendux
      @bendux  6 місяців тому +1

      The ground check must be a child of the player.

  • @jimmykendrick45
    @jimmykendrick45 6 місяців тому

    I'm at 4:55 and the script has no spaces for me to drag in the references. Some of the code I was writing didn't light up like yours either, so that may have something to do with it. Would you know a fix?

    • @bendux
      @bendux  6 місяців тому

      Make sure that the script is saved and doesn't contain any errors.

    • @jimmykendrick45
      @jimmykendrick45 6 місяців тому

      @@bendux thanks for the reply! I finally found it out thanks to a very small video I found after hours of searching😂 I had to change the “external script editor” to Visual Studio, as it was set to “file extension” by default for some reason.