2D Player Movement In Unity

  Рет қаралды 398,417

bendux

bendux

2 жыл бұрын

Learn how to move and jump in Unity!
Source code: gist.github.com/bendux/5fab0c...
SOCIAL
Discord: / discord
itch.io: bendux.itch.io/
Twitter: / bendux_studios
SUPPORT
Buy Me a Coffee: www.buymeacoffee.com/bendux
MUSIC
By the Fireplace by TrackTribe
Home for the Holidays by TrackTribe

Пікірлер: 2 000
@ErraticPulse
@ErraticPulse Жыл бұрын
Fun Fact, if u look at some of the areas on the script window you will notice that the language is in german
@dumsparaside
@dumsparaside 4 ай бұрын
yes I found out
@guyinaraincoat4292
@guyinaraincoat4292 Жыл бұрын
This tutorial was very helpful by showing the whole process of making the script that made the character move, Thank you!
@fluffystuff
@fluffystuff Жыл бұрын
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 Жыл бұрын
Yeah what in the world is going on here ._.
@Skitozzz
@Skitozzz Жыл бұрын
@@Externium :)
@deilruchi
@deilruchi Жыл бұрын
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 Жыл бұрын
Been working on this issue for literally weeks, bless you wise internet stranger!
@deilruchi
@deilruchi Жыл бұрын
@@joshpreston4957 Glad it helped you, because it took me a while as well.
@mariazia221
@mariazia221 Жыл бұрын
where
@deilruchi
@deilruchi Жыл бұрын
@@mariazia221 kzbin.info/www/bejne/gWLbi2CorsiMj5o
@Garfield_Minecraft
@Garfield_Minecraft Жыл бұрын
OMG thank you god it's been 3 hours just sitting here what went wrong
@enderpigerdragon3589
@enderpigerdragon3589 9 ай бұрын
Thanks for the awesome 2D movement in Unity tutorial! Super helpful! 👍
@schauerv
@schauerv Жыл бұрын
God tier tutorial, finally something that is short and works great instead of an 18 min video that bugs out!
@Skitozzz
@Skitozzz Жыл бұрын
Fr fr
@historyjunior
@historyjunior Жыл бұрын
This is an amazing tutorial! Thank you so much, I really loved this!
@monkeypwners
@monkeypwners 9 ай бұрын
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!
@JustSplatoonGameplay
@JustSplatoonGameplay Жыл бұрын
Hey! Just wondering, if we want to animate, what boolean or Float should i use for the transition?
@mangmoommoommoom2000
@mangmoommoommoom2000 Ай бұрын
Yeah bro I was about to ask tha’
@nagisa1578
@nagisa1578 Жыл бұрын
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.
@FireGloves
@FireGloves 8 ай бұрын
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 8 ай бұрын
It doesn’t work even if I press space though 🫤
@dalegacy2877
@dalegacy2877 7 ай бұрын
@@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 7 ай бұрын
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
@swiniapierdek
@swiniapierdek 6 ай бұрын
omg thank you I haven't knew that.
@TheGreyCat1026
@TheGreyCat1026 6 ай бұрын
that was the problem, thanks!@@zanahtile6276
@polyhedrainteractive9663
@polyhedrainteractive9663 7 ай бұрын
This is incredible, I coded for a while but couldn't get past the basics will watch more
@The_Gronne
@The_Gronne Жыл бұрын
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.
@notwasnttaken
@notwasnttaken Жыл бұрын
Mee too, i give it 100/100!
@LilCouve
@LilCouve Жыл бұрын
Thank you, this was my first time using C# and this really helped me!
@lennystudios3.14
@lennystudios3.14 7 ай бұрын
Love it, I personally like adding a Lerp function for some smoother acceleration and floatier physics, but that’s just my prefrance
@yugnatata
@yugnatata 2 ай бұрын
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!
@Skylar.H93
@Skylar.H93 Жыл бұрын
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 Жыл бұрын
I'm glad I could help. Good luck!
@LucaThePupineer
@LucaThePupineer 5 ай бұрын
HOW THIS FEELS IMPOSSIBLE
@lemason5981
@lemason5981 Жыл бұрын
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 Жыл бұрын
Haha, I'm definitely not a wizard.
@NewSunnahAcquired
@NewSunnahAcquired 19 күн бұрын
@@bendux thats exactly what a wizard would say
@yumura137
@yumura137 10 ай бұрын
very simple yet satisfying and fun movement, straight to the point video, simply one of best on youtbe
@francheeze
@francheeze 10 ай бұрын
Simple, quick & elegant. Nice!
@amburdo6206
@amburdo6206 Жыл бұрын
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 Жыл бұрын
Edit > Project Settings > Input Manager
@amburdo6206
@amburdo6206 Жыл бұрын
@@bendux Thanks a lot!
@lilili765
@lilili765 7 ай бұрын
​@@benduxwhat do i do in inputmanager
@matsu4721
@matsu4721 2 жыл бұрын
Thanks for this awesome smooth moving video, but can you do 2d enemy ui or shooting?
@bendux
@bendux 2 жыл бұрын
I've added it to my list. Thank you for the suggestion!
@ZephyrAnimationss
@ZephyrAnimationss 2 жыл бұрын
@@bendux YEsssssss exactly what i wanted thanks(i want to make a shooter game cuz im new)
@Tapov_
@Tapov_ Жыл бұрын
Thanks for the tutorial! I'm a beginner and this helps alot!
@JohnKirk-eb6nk
@JohnKirk-eb6nk Жыл бұрын
I have watched tons of tutorials, best one yet
@W5AKC
@W5AKC 2 жыл бұрын
Very nice and simple.
@mitchelllockyer7541
@mitchelllockyer7541 Жыл бұрын
bippity boopity your code is now my property
@vrsuhfx
@vrsuhfx Жыл бұрын
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 Жыл бұрын
The answer to your question goes beyond the scope of a KZbin comment, but I'd still like to help you. Join our Discord server, and let's solve your problem together!
@Jamal38852
@Jamal38852 Жыл бұрын
You literally saved me by making this video, earned a sub
@its_a_gamer5279
@its_a_gamer5279 Жыл бұрын
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 Жыл бұрын
Thank you for sharing!
@its_a_gamer5279
@its_a_gamer5279 Жыл бұрын
@@bendux np!
@wogs2k
@wogs2k Жыл бұрын
I did this and it still doesn't work
@bendux
@bendux Жыл бұрын
@@wogs2k Join our Discord server, and let's solve your problem together!
@sirnoodle2004
@sirnoodle2004 Жыл бұрын
@@wogs2k Also make sure that on both the BoxCollider2D of the player and the platforms, the box "Is Trigger" is not ticked
@slayerghande7969
@slayerghande7969 2 жыл бұрын
Yo, great work here 👏. Don't ever stop and you will be the new brackeys
@eshaanb2362
@eshaanb2362 16 күн бұрын
Thank you so much, this tutorial was very helpful!
@BILGI_PASA
@BILGI_PASA Жыл бұрын
Thank you bendux. The video helped me so much.
@alexwellman6605
@alexwellman6605 Жыл бұрын
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 Жыл бұрын
Add a Composite Collider 2D component to your tilemap.
@alexwellman6605
@alexwellman6605 Жыл бұрын
@@bendux thank you so much
@cheezeburger7716
@cheezeburger7716 Жыл бұрын
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 Жыл бұрын
Would you like to show me your code on Discord?
@cheezeburger7716
@cheezeburger7716 Жыл бұрын
@@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 Жыл бұрын
@@cheezeburger7716 I'm glad you were able to fix it.
@ab7299
@ab7299 Жыл бұрын
@@cheezeburger7716 can you tell me how you fixed it? i want to fix it too
@aniime4006
@aniime4006 Жыл бұрын
@@cheezeburger7716 can you tell me how you fixed it? i want to fix it too
@foo3268
@foo3268 2 жыл бұрын
underrated channel, hopefully unity notices you someday
@potato_legend127
@potato_legend127 Жыл бұрын
Thank you for this video. It helped me a lot!!!
@feddyfadbear7985
@feddyfadbear7985 2 жыл бұрын
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 Жыл бұрын
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!
@frogwav
@frogwav Жыл бұрын
You explained this well. also it works. thanks!
@gameormusic2360
@gameormusic2360 11 ай бұрын
bro is definitely not a beginner, Very helpful video and thank you
@KenB1206
@KenB1206 10 ай бұрын
thank you so much, sir bendux! it help quite significantly
@Nintendostar02
@Nintendostar02 Жыл бұрын
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 Жыл бұрын
I've added it to my list. Thank you for the suggestion!
@krzaczastyyt6547
@krzaczastyyt6547 2 жыл бұрын
Your tutorials are the best i gona make a game with those
@markotafa
@markotafa 6 ай бұрын
I like people that actually put code in the despcription :)
@artofarii
@artofarii Жыл бұрын
Nicely Explained. Thank you so much!
@K9Arrzee
@K9Arrzee 11 ай бұрын
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 10 ай бұрын
yo, my serialized fields arent showing up in my unity project and i was wondering if you could help
@noona7701
@noona7701 9 ай бұрын
@@wizard7317 did u save the script in vs before going back to unity?
@furyz0339
@furyz0339 8 ай бұрын
this script gives me no movements :c i turn left and right but cannot move
@noona7701
@noona7701 8 ай бұрын
@@furyz0339 you have to change the speed in vscode to 8 (in the comment it is set to 0)
@furyz0339
@furyz0339 8 ай бұрын
thank youuu @@noona7701
@EmirDuman1
@EmirDuman1 4 ай бұрын
i can't jump
@finngrainger349
@finngrainger349 4 ай бұрын
neither, left and right works just no jump
@wayvoedorado71
@wayvoedorado71 4 ай бұрын
have any of you found a solution yet? It looks like it's a common problem.
@finngrainger349
@finngrainger349 4 ай бұрын
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 4 ай бұрын
@@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 3 ай бұрын
You probably skipped one or two important steps in the tutorial.
@r.ssolanki4841
@r.ssolanki4841 Жыл бұрын
Very well explained, thanks a lot!!
@DevNoob
@DevNoob 2 жыл бұрын
Always good videos! 1k subs let's go!
@RichardBarnes0
@RichardBarnes0 2 жыл бұрын
The old input system is not worth using anymore.
@lilDrizzyyy
@lilDrizzyyy Жыл бұрын
Yes it is stfu
@VonMoosHarrison
@VonMoosHarrison Жыл бұрын
Literaly the most difficult to understand tutorial
@Think_Stream
@Think_Stream 11 ай бұрын
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 11 ай бұрын
Brackys tutorial is where all the souls go😂😂
@c0rse198
@c0rse198 Жыл бұрын
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.
@debramciver307
@debramciver307 Жыл бұрын
HELP PLEASE
@everything-editz785
@everything-editz785 Жыл бұрын
Best unity tutorial i havrme ever seen 10/10
@travisc8406
@travisc8406 Жыл бұрын
can we just appreciate that he is still responding to comments! you're awesome!
@carlosalbertobatistacruz
@carlosalbertobatistacruz 7 ай бұрын
Nice tutorial, the SpriteRenderer Component can also be used, just get the flipX (bool) attribute, instead of using localScale -1.
@xsool-yl7us
@xsool-yl7us Жыл бұрын
this help out a ton thanks man
@atauygur8104
@atauygur8104 7 ай бұрын
I understand that if the movement button is pressed down continuously there will be no errors, but doesn't this code have a possibility to miss input when we just pressed for a small time? Because, there is nothing to prevent "horizontal" variable to be updated multiple times between two consecutive "FixedUpdates".
@dmitriyleonov6977
@dmitriyleonov6977 6 ай бұрын
Отлично. Я делал подобный урок от другого автора. Персонаж дёргался. А тут всё движется плавно и код выполнен здорово компактно. Настройки физического тела показал как настроить . Спасибо за урок
@chrono9503
@chrono9503 10 ай бұрын
is it possible to assign the properties of the "jump" button to a ui button? I want this code to work with my mobile game
@beepboop2851
@beepboop2851 Жыл бұрын
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 Жыл бұрын
The source code on GitHub is the same as in the video.
@antoniosalazar9505
@antoniosalazar9505 Жыл бұрын
Thanks, I was just looking for this.
@dennisestepro
@dennisestepro Жыл бұрын
Hey! I am wondering how can I stop the player from moving when he hits the edge of the screen? If I just add an if to check the transform.position.x is lower or higher than the value of the edge of the screen, the player just keeps on going without me touching any buttons. Any opinions?
@bendux
@bendux Жыл бұрын
You could create an empty game object and add a Box Collider 2D component to it.
@shinsane1558
@shinsane1558 Жыл бұрын
Hey! i got a problem, its saying this in the console: Assets\PlayerMovement.cs(13,30): error CS0246: The type or namespace name 'RigidBody2D' could not be found (are you missing a using directive or an assembly reference?)
@bendux
@bendux Жыл бұрын
Try Rigidbody2D instead of RigidBody2D.
@hellopeople2395
@hellopeople2395 2 ай бұрын
thank you just curious why does rb.velocity = new Vector2(horizontal * speed, rb.velocity.y); have to be in fixed update
@loawkkx
@loawkkx Жыл бұрын
With this configuration, do you know how I can affect the velocity in another way because it is defined at each frame? I can't affect the velocity in any other script at all
@bendux
@bendux Жыл бұрын
The answer to your question goes beyond the scope of a KZbin comment, but I'd still like to help you. Join our Discord server, and let's solve your problem together!
@tunahanyilmazdev
@tunahanyilmazdev 2 жыл бұрын
Great as always!
@Prod_Joel-beats
@Prod_Joel-beats 9 ай бұрын
What buttons do you move left and right on? I can jump but idk how to love left and right
@bendux
@bendux 9 ай бұрын
Edit > Project Settings > Input Manager
@ukasz4848
@ukasz4848 4 күн бұрын
Hi, would't this solution allow jumping mid-air after falling from a platform?
@kidthelett
@kidthelett 2 ай бұрын
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
@BarrowWight
@BarrowWight Жыл бұрын
Which button input is used to jump? I know this is a dumb question but I followed the code exactly and tried all buttons on my keyboard but not triggered any sort of jumping action.
@bendux
@bendux Жыл бұрын
Did you position the ground check at your player's feet?
@BarrowWight
@BarrowWight Жыл бұрын
Hadn't checked that. thanks for the advice :)
@felixkostur723
@felixkostur723 11 ай бұрын
thx this was really useful and it works for me
@Nexorix_
@Nexorix_ Жыл бұрын
Am a noob in c sharp and it worked intantly Thanks man !
@mr.animation3588
@mr.animation3588 2 жыл бұрын
how do i know what the exect size of the square you put on the "sprite renderer"?
@bendux
@bendux 2 жыл бұрын
docs.unity3d.com/Manual/SpriteCreator.html
@Bashi_boi
@Bashi_boi 3 ай бұрын
Really helpful tutorial thanks :)
@smr-moon
@smr-moon Жыл бұрын
Hi! How do we change the movement keys? The default is that Jump is the space, and sideway movements are A-D / R-L Arrow... I want to manipulate this. Thanks
@bendux
@bendux Жыл бұрын
Edit > Project Settings > Input Manager
@smr-moon
@smr-moon Жыл бұрын
Found it! Thanks! Great video :D
@-._122
@-._122 10 ай бұрын
@bendux THIS IS THE BEST TUTORIAL EVER!!! I CAN MOVE AND JUMP btw you just earned a sub
@bendux
@bendux 10 ай бұрын
Thank you!
@-._122
@-._122 10 ай бұрын
@@bendux no problem
@dkoorse
@dkoorse Жыл бұрын
I have a problem. when my lil guy goes on a slope he cant jump. only on top of it. edit: i used a circle collider 2d, but now when im walking left on the slope and i turn right he does a lil jump. why??? Can u mr. bendux help me?
@Hollowdude15
@Hollowdude15 Жыл бұрын
Unity is so cool and nice video man :]
@dr.w2800
@dr.w2800 8 ай бұрын
When i try to open the player mouvement script, it propose me to go into note or opera etc like if it was just a text file, it dosent open it, anyone know how to fix it ? Edit : I installed Visual studio it works fine now
@orionsayshi5037
@orionsayshi5037 Жыл бұрын
I'm wanting to lock the position of the camera to the player as it moves. When I try and do so it seems like something is constantly flipping and causing the camera to shake back and forth. Is there a way to prevent this?
@bendux
@bendux Жыл бұрын
We have a solution for that on our Discord server. Feel free to join!
@roundfuzball88
@roundfuzball88 Жыл бұрын
thank you for this tutorial but i keep on getting one error when i add the movement can you tell me how to fix this? the error is "Assets\CharacterController.cs(17,5): error CS8803: Top-level statements must precede namespace and type declarations."
@bendux
@bendux Жыл бұрын
There is a link to the source code in the description.
@AyahA-ok1gd
@AyahA-ok1gd Жыл бұрын
hi, so I used a different script for making my player move because I wanted two different players who used different controls, but when I tried to follow your script to make the player flip, it won't work. the most that I got to happen was when I play the game, the player immediately flips to the left, but doesn't flip anymore after. Do you have any idea of why this could happen?
@bendux
@bendux Жыл бұрын
Would you like to show me your code on Discord?
@Mooshie318
@Mooshie318 Жыл бұрын
How do I increase the gravity to make the player jump/fall faster? Also sometimes my player gets stuck to the ground and I can't really move until I jump, how do I fix that?
@bendux
@bendux Жыл бұрын
Increase the gravity scale of your player's Rigidbody 2D component. If you have a tilemap in your scene, add a Composite Collider 2D component to it.
@baovirus2004
@baovirus2004 8 ай бұрын
every thing works, but when i add animation, my character can't move, can you help me
@RelaxReisen
@RelaxReisen Жыл бұрын
Danke, hat problemlos geklappt!
@eylul2140
@eylul2140 Жыл бұрын
Your tutorial is great ♥
@colinobrien1278
@colinobrien1278 Жыл бұрын
Love this Tutorial! but is there a way to change the keys that control movement? I want to change the space button to the W key to jump.
@bendux
@bendux Жыл бұрын
Edit > Project Settings > Input Manager
@colinobrien1278
@colinobrien1278 Жыл бұрын
@@bendux Thanks you so much!
@Hyper_alexa
@Hyper_alexa Жыл бұрын
that is helping me a lot man tnx
@woslake7576
@woslake7576 Жыл бұрын
Thanks !! I love your video.
@Twelvyshandle
@Twelvyshandle Жыл бұрын
There is something im having a problem with. i did not set up the input for "jump" when i changed the "jump" to "space" i needed an input system for it so uuhh help?
@bendux
@bendux Жыл бұрын
Edit > Project Settings > Input Manager
@DeApple_king
@DeApple_king Жыл бұрын
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 Жыл бұрын
If you have a tilemap in your scene, add a Composite Collider 2D component to it.
@Esteban_Santos
@Esteban_Santos Жыл бұрын
Hi! great tutorial! i cant get my jump falloff to work I mean jumping least when just tapping the button, can it be due to the scale of my objects?
@bendux
@bendux Жыл бұрын
Would you like to show me your code on Discord?
@KrixerVR
@KrixerVR 3 ай бұрын
This helped me alot and I even somehow got my player to infinite jump like flappy bird. Definitally a win
@bendux
@bendux 2 ай бұрын
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 2 ай бұрын
@@bendux Thx man, oh and btw I subbed to you for your awesome Unity tips!!
@bendux
@bendux 2 ай бұрын
@@KrixerVR I appreciate it. Thank you!
@user-ef8yw9mq8p
@user-ef8yw9mq8p Жыл бұрын
Hey! Nice video =) But I can't using rb.velocity moving aproach with moving platforms... Player is sliding from the moving platform =( How I can fix it? transfom.parent and ph material with friction is doesn't work becouse velocity is changing directly in rb.
@AreHorsesReal
@AreHorsesReal Жыл бұрын
Slight issue with something, not entirely sure why but moving left/right causes the Y value on the rigidbody's velocity to also go up, even though you're not moving along the Y axis. This messes with some jump/falling animations I have, and I can't seem to figure out why the y value is anything but zero when I move left or right on flat ground.
@diamondfiremc2514
@diamondfiremc2514 Жыл бұрын
make sure your platform that you made is flat, if it is 1 pixel higher in one spot it could do that, if not then I have no idea lol
@AreHorsesReal
@AreHorsesReal Жыл бұрын
@@diamondfiremc2514 I got it figured out, it was an issue with the composite collider on a tilemap causing it to be set extremely close to zero like 4.82629e-8 or something. Thanks for the fast response tho
@diamondfiremc2514
@diamondfiremc2514 Жыл бұрын
@@AreHorsesReal never considered that but now that you say it, that explains everything lol, no problem as well, just happened to be in the right place at the right time
@Clyret0
@Clyret0 Жыл бұрын
it works very well but I can't add an animated idle model to it because when the boxcollider comes into contact with the ground, the model goes crazy and falls left and right even sometimes upside down. i did a lot of research to fix this but I couldn't find any code that works correctly. can you help me?
@bendux
@bendux Жыл бұрын
Freeze the rotation of your player's Rigidbody 2D component.
@arekusandoru8543
@arekusandoru8543 6 ай бұрын
My VScode show an error at rb.velocity = new Vector2(horizontal * speed, rb.velocity); to be more specific is in Vector2. Anybody can help me?
@bendux
@bendux 6 ай бұрын
rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
@chrono9503
@chrono9503 10 ай бұрын
Its better to use a trigger colider instead of an empty object to check for grounded so you can change the width
@bendux
@bendux 10 ай бұрын
You can adjust the radius of the ground check.
@Brian-pf6yb
@Brian-pf6yb Жыл бұрын
how do you assign the jump to the spacebar and the move keys to the right and left arrow keys?
@bendux
@bendux Жыл бұрын
Edit > Project Settings > Input Manager
@luke_faramelli
@luke_faramelli Жыл бұрын
I had this running perfectly, but when I change my sprite to one I created, it moves but won’t jump anymore. Is there any reason why?
@bendux
@bendux Жыл бұрын
Did you position the ground check at your player's feet?
@pringleguy
@pringleguy 10 ай бұрын
Hey, I am having a difficult time with the gravity, when I press play, the player object just falls off screen, but if i set gravity to 0 it just floats, what do I do?
@pringleguy
@pringleguy 10 ай бұрын
I take back my statement, what I did wrong was that I forgot to give the platforms a box collider lol
How To Dash In Unity
3:53
bendux
Рет қаралды 128 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 3,8 МЛН
Why You Should Always Help Others ❤️
00:40
Alan Chikin Chow
Рет қаралды 98 МЛН
Китайка и Пчелка 10 серия😂😆
00:19
KITAYKA
Рет қаралды 1,9 МЛН
When someone reclines their seat ✈️
00:21
Adam W
Рет қаралды 24 МЛН
Why Does Celeste Feel So Good to Play?
17:34
Game Maker's Toolkit
Рет қаралды 2,6 МЛН
I Made a Neural Network with just Redstone!
17:23
mattbatwings
Рет қаралды 521 М.
20+ Minecraft Things You Probably Forgot About
12:48
Skip the Tutorial
Рет қаралды 161 М.
TOP DOWN MOVEMENT in Unity!
22:30
Brackeys
Рет қаралды 1,2 МЛН
Animation vs. Physics
16:08
Alan Becker
Рет қаралды 23 МЛН
How Do Games Render So Much Grass?
15:52
Acerola
Рет қаралды 316 М.
Code Class - 2D Player Movement in Unity
29:02
AdamCYounis
Рет қаралды 25 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 390 М.
Unity 2D Player Move and Jump with Groundcheck Tutorial
11:13
MoreBBlakeyyy
Рет қаралды 44 М.
#miniphone
0:16
Miniphone
Рет қаралды 2,7 МЛН
МОЩНЕЕ ТВОЕГО ПК - iPad Pro M4 (feat. Brickspacer)
28:01
ЗЕ МАККЕРС
Рет қаралды 55 М.
сюрприз
1:00
Capex0
Рет қаралды 1,2 МЛН
Main filter..
0:15
CikoYt
Рет қаралды 2,9 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 4,7 МЛН