Unity 2D Platformer Player Controller - Player Jump & Ground Check

  Рет қаралды 27,482

Charger Games

Charger Games

Күн бұрын

Пікірлер: 86
@ChargerGames
@ChargerGames 4 жыл бұрын
Move To Any Specific Part Of The Video(Click Below): 1. 00:00 - Intro 2. 00:50 - Explaining The Movement Code 3. 01:36 - Creating The Jump Function 4. 04:03 - Making The Jump Better 5. 05:18 - Fixing Multiple Jumping 6. 07:07 - Code for Ground Check 7. 11:50 - Final Play Testing [Get My New Course] Build 20+ Mini projects with Unity : bit.ly/3bLn4Ns
@saqibjaved1900
@saqibjaved1900 Жыл бұрын
God bless you brother, i've been stuck on ground check for last two days, and your this video solved my issue, thank you soo much. Keep doing this amazing stuff. subscribed,liked 🙂
@ChargerGames
@ChargerGames Жыл бұрын
Glad I could help , Happy Learning :)
@prathamesh_sinha
@prathamesh_sinha 3 жыл бұрын
You actually saved my life. An important game jam was too close(4 days) and i hadn't even done at least 30% as i was stuck in the ground check function. today after watching 17 waste videos, came to you and saved my life tho have my sub and like for sure. hope you keep on making awesome videos like this and grow up your channel. best of luck for your cool future!😘
@Mbuso.B.Dlamini
@Mbuso.B.Dlamini 4 жыл бұрын
You r so underrated bro I’m surprised that you dont have a Million subscribers yet
@ChargerGames
@ChargerGames 4 жыл бұрын
Thanks for supporting bro.. I'll keep try to keep uploading irrespective of my subscriber count :)
@lordcatington8188
@lordcatington8188 4 жыл бұрын
Loving all the videos coming out recently!
@ChargerGames
@ChargerGames 4 жыл бұрын
Glad to know it.. :)
@CatStorm-gb5bx
@CatStorm-gb5bx 3 жыл бұрын
I already had a jumping mechanic so i didn´t need the first parts of the video. But the Ground check worked perfectly with my script. So thank you for that.
@HugiHugison
@HugiHugison 4 жыл бұрын
After trying for hours, your video was the one that really helped me
@ChargerGames
@ChargerGames 4 жыл бұрын
Glad it helped :)
@EricGames117
@EricGames117 Жыл бұрын
Thanks! Super new to Unity (and C#) and everyone else has such complicated ways to program this. Thanks for making it simple!
@ChargerGames
@ChargerGames Жыл бұрын
Glad it was helpful!
@williamlima4877
@williamlima4877 4 жыл бұрын
Im brazilian, and i was having bugs on my game! And this video show me a geniusly way to solve it! You r amazing bro!!!
@Abdul-pe5rf
@Abdul-pe5rf 4 жыл бұрын
I love your tutorial, unlike a lot of other creator, I understand everything you said.
@digijam3568
@digijam3568 3 жыл бұрын
Thank you very much for this! I was having an absolute nightmare trying to stop the double jump, your suggestion is the only one I have found that actually works :)
@jakuba5050
@jakuba5050 3 жыл бұрын
Best Ground Check tutorial i've ever seen. Great work!
@mugan86
@mugan86 4 жыл бұрын
Thank you very much for the tutorial, very clear and very well structured, raising the complexity in an intelligent way. I'm negatively surprised that you don't have more subscribers since the content you offer is very very good. Congratulations and thanks again! p.d.- here a follower who will be attentive to new content with the bell activated;)
@pavelpolosin2217
@pavelpolosin2217 Жыл бұрын
Thanks man. I tried to create ground checking system with Physics2D.Raycast, and with Physics2D.Linecast, but only with your way (OverLapCircle), I finally made it!
@ChargerGames
@ChargerGames Жыл бұрын
Glad I could help!
@adhviklalthoppe2214
@adhviklalthoppe2214 4 жыл бұрын
I love ur vids and without u I would have no C# knowledge so thank u for everything u do
@ChargerGames
@ChargerGames 4 жыл бұрын
Thank You, I'm so happy to know that I could help you learning :)
@subhanatakisiyev7830
@subhanatakisiyev7830 4 жыл бұрын
thank you! i couldn't fix groundcheck for weeks!
@davestomper3428
@davestomper3428 4 жыл бұрын
Hi liked the video some really good information thanks. My question is if you had a game and let's say you use space bar to swim up I think original Super Mario Bros used the jump button and the swim up button using the same button. So in this case would a ground check be a problem would it need to be done differently somehow. I want to add swimming to a few levels
@ChargerGames
@ChargerGames 4 жыл бұрын
Are you a Student in any of My Udemy Courses?
@sarthakghodke7250
@sarthakghodke7250 4 жыл бұрын
Yes
@V.Z.69
@V.Z.69 4 жыл бұрын
Ah, I've taken course on Udemy. I was studying 3D modeling and Rigging. No time to continue that right now. But it's fair that you are on Udemy. Your time is important and you can't just rely on KZbin to pay for your content even if it is monetized. Besides, a bikini-haul get's millions of views and it takes zero effort and no talent. That's the world, a sexy model makes millions when engineers struggle to make 70K a year.
@AliHaider-jy1pr
@AliHaider-jy1pr 4 жыл бұрын
Dont know teacher why are you soo underrated by the way i am learning from your course and its awsome teacher thank you 😍.
@ChargerGames
@ChargerGames 4 жыл бұрын
Thank you! 😃 Which course have you taken?
@sarthakghodke7250
@sarthakghodke7250 4 жыл бұрын
Love your videos bro
@ChargerGames
@ChargerGames 4 жыл бұрын
Thanks man
@roadtrpr
@roadtrpr 4 жыл бұрын
made it possible for me to integrate with other source code and go little "off piste" and improvise here. Many thanks. Really good explained.
@kuttykoranguedits1154
@kuttykoranguedits1154 2 жыл бұрын
LOVE FROM TN ❤️🤩
@Game-Echo1988
@Game-Echo1988 3 жыл бұрын
Thank you so much. this is exactly what I needed
@harshitabakre3714
@harshitabakre3714 4 жыл бұрын
Thanks i really wanted this
@ChargerGames
@ChargerGames 4 жыл бұрын
Good timing for you :D
@abhizidane3
@abhizidane3 4 жыл бұрын
Hi Raja ... amazing video as always...
@ChargerGames
@ChargerGames 4 жыл бұрын
Thanks Abhishek :)
@amazingproducts-sahilview3916
@amazingproducts-sahilview3916 3 жыл бұрын
thanks sir for this amazng tutorial.
@MrGoldenBee
@MrGoldenBee 4 жыл бұрын
Thanks for the tutorials
@ChargerGames
@ChargerGames 4 жыл бұрын
Thanks for checking out :)
@OkaToka
@OkaToka 2 жыл бұрын
For a some reason in my case character doesn't jump everytime I press jump button, but skips 2-3 presses.
@SumanDeyMusic
@SumanDeyMusic 4 жыл бұрын
Wow.. sueprb video 😁😁
@ChargerGames
@ChargerGames 4 жыл бұрын
Thanks a lot 😊
@bezinteresa6806
@bezinteresa6806 4 жыл бұрын
Шикарные видео. Хочу попробоваать сделать игру, но лень начинать)))
@ChargerGames
@ChargerGames 4 жыл бұрын
Keep Learning :)
@AliHaider-jy1pr
@AliHaider-jy1pr 4 жыл бұрын
Teacher would you please make videos on unity animation .. i learn a lot from you..
@ChargerGames
@ChargerGames 4 жыл бұрын
Ya sure.. :)
@DavezinhoDDR
@DavezinhoDDR 4 жыл бұрын
i'm having trouble cuz i'm using some sloped platforms. It adds too much force when i'm running and too less when i'm standing in them. Plz help
@techbit7607
@techbit7607 3 жыл бұрын
Once I add this code my character slightly bounces a little bit, how do I stop that from happening?
@amazingproducts-sahilview3916
@amazingproducts-sahilview3916 3 жыл бұрын
sir how i can code a player to dig the ground.
@1Happy_Singh
@1Happy_Singh 4 жыл бұрын
Please Make A Vudeo On " Spring Joints "
@Diamond-yn4nu
@Diamond-yn4nu 4 жыл бұрын
Nice video keep going 🖒
@padilla190
@padilla190 3 жыл бұрын
WHAT IM DOING BAD ;C if (Input.GetKeyDown(KeyCode.Space)) { if(isGrounded){ Jump(); Debug.Log("Algo anda mal"); } Debug.Log("precionaste espcacio"); } i put a debug.log to confirm if i pressed space and it works but now my player doesnt jump ;/
@gk9257
@gk9257 3 жыл бұрын
you are awesome! Thanks
@Galaxy_World
@Galaxy_World 2 жыл бұрын
NullReferenceException: Object reference not set to an instance of an object PlayerMovement1.Jump () (at Assets/Scripts/PlayerMovement1.cs:10) PlayerMovement1.Update () (at Assets/Scripts/PlayerMovement1.cs:26) :|
@tinycole1239
@tinycole1239 3 жыл бұрын
I keep getting a bug that says "Physics2D" does not contain a definition for 'OverLapCircle'. Does anyone know how i can fix that?
@patrikpatrik2532
@patrikpatrik2532 2 жыл бұрын
type OverlapCircle instead of OverLapCircle
@timovh2527
@timovh2527 3 жыл бұрын
Thank you so much!
@bhaskarakeerthi2235
@bhaskarakeerthi2235 4 жыл бұрын
iam not able to find the script for walking cat
@keyinteriordesigners2390
@keyinteriordesigners2390 3 жыл бұрын
Hi in my 2D game public float doesn't work I used it as public float speed but the float didn't work but it works for my 3D game
@picklezszs
@picklezszs 2 жыл бұрын
what a W tysm
@st3fke882
@st3fke882 4 жыл бұрын
Hi it wont work for me, can you help? I didnt recive any errors. Code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { private Rigidbody2D rb; public float movementSpeed; private Animator myAnimator; private bool facingRight; private bool attack; public float jump; bool isGrounded; public Transform groundCheck; public LayerMask groundlayer; void Start() { facingRight = true; rb = GetComponent(); myAnimator = GetComponent(); } void Update(){ HandleInput(); } void FixedUpdate() { float horizontal = Input.GetAxis("Horizontal"); HandleMovement(horizontal); Flip(horizontal); HandleAttacks(); ResetValues(); isGrounded = Physics2D.OverlapCircle(groundCheck.position,1f, groundlayer); } private void HandleMovement(float horizontal) { if (myAnimator.GetCurrentAnimatorStateInfo(0).IsTag("Attack")) { return; } rb.velocity = new Vector2(horizontal * movementSpeed, rb.velocity.y); myAnimator.SetFloat("speed",Mathf.Abs(horizontal)); } private void Flip(float horizontal) { if (horizontal > 0 && !facingRight || horizontal < 0 && facingRight) { facingRight = !facingRight; Vector3 theScale = transform.localScale; theScale.x *= -1; transform.localScale = theScale; } } private void HandleAttacks() { if (attack) { myAnimator.SetTrigger("attack"); } } private void HandleInput() { if (Input.GetKeyDown(KeyCode.Space)) { if (isGrounded){ rb.velocity = new Vector2(rb.velocity.x, jump); } } if (Input.GetMouseButtonDown(0)){ attack = true; } } private void ResetValues(){ attack = false; } }
@kushagrajaiswal4066
@kushagrajaiswal4066 2 жыл бұрын
It shows physics2d does not exist??
@hassanmaswedish2290
@hassanmaswedish2290 3 жыл бұрын
Thank you raja baja
@alibayat1336
@alibayat1336 4 жыл бұрын
thank you!
@radjagunasilinjulia8435
@radjagunasilinjulia8435 4 жыл бұрын
Make one video for visual scripting ..
@ChargerGames
@ChargerGames 4 жыл бұрын
Yes, I want to create a video on Bolt Visual Scripting
@coleslaw7689
@coleslaw7689 2 жыл бұрын
So I have been trying this and it seems that I might've done something wrong because I keep on getting an error so can someone please tell me (btw I added a different movement script I'm also new to scripting) This is my script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { public float jump Force(); public float moveSpeed = 5f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f); transform.position += movement * Time.deltaTime * moveSpeed; if (Input.GetKetDown(KeyCode.Space)) { jump(); } } void Jump() { rb.velocity = Vector2.up * jumpForce; } }
@sabrinahafenberg7241
@sabrinahafenberg7241 2 жыл бұрын
the "public float jump Force()" is wrong it should be "public float jumpForce;" Then it's right. The whole script would be then: using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { public float jumpForce; public float moveSpeed = 5f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f); transform.position += movement * Time.deltaTime * moveSpeed; if (Input.GetKetDown(KeyCode.Space)) { jump(); } } void Jump() { rb.velocity = Vector2.up * jumpForce; } }
@pewpewjello7904
@pewpewjello7904 4 жыл бұрын
nice!
@darealspawn
@darealspawn 3 жыл бұрын
All works but when up arrow key is pushed the y movement is happening :) should this happen. I guess i need to remove the yInput part :)
@quikx8520
@quikx8520 4 жыл бұрын
I did not get the notification?
@ChargerGames
@ChargerGames 4 жыл бұрын
You can press the Bell icon beside subscribe button, if you're not getting notifications. I have also uploaded Double Jump video few Today..
@justusisbestest4122
@justusisbestest4122 2 жыл бұрын
THANK YOU SO FUCKING MUCH OMG
@ChargerGames
@ChargerGames 2 жыл бұрын
Glad it helped :)
@justusisbestest4122
@justusisbestest4122 2 жыл бұрын
@@ChargerGames my jumping was bugged but thanks to u it worked :D
@kartikpathak629
@kartikpathak629 4 жыл бұрын
Bro WHEN WILL MOBILE FPS COME??????????
@mannou38
@mannou38 3 жыл бұрын
BRUH WHY IS THIS NOT WORKING- this is so embarassing. i have been using unity for over 3 years at this point yet i cannot get this to work. i literally was going to code this myself in 5 minutes yet here i am spending hours stuck.. player doesn't move at all. i tried everything.
@senthilkumar6922
@senthilkumar6922 4 жыл бұрын
Please reply your language
@hassanmaswedish2290
@hassanmaswedish2290 3 жыл бұрын
Raja the kala
@STEEZY2BREEZY
@STEEZY2BREEZY 4 жыл бұрын
6th comment yessir >:)
@ChargerGames
@ChargerGames 4 жыл бұрын
Yay
@STEEZY2BREEZY
@STEEZY2BREEZY 4 жыл бұрын
@@ChargerGames OMG NO WAY YOU RESPONDED YOU ARE MY FAVIROTE KZbinR OMGGGGGGGG HIIII
@omanshsharma292
@omanshsharma292 4 жыл бұрын
20th comment!!!
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
Learn C# Scripting for Unity 2D Game Development in 20 Minutes
19:30
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
4 Ways to Code 2D Player Movement in Unity (You SHOULD know these!)
16:24
Lost Relic Games
Рет қаралды 173 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 785 М.
Why I am NOT Making These Enemies
17:06
Deynum Studio
Рет қаралды 214 М.
Idle, Run and Jump Animations - Platformer Unity 2D
10:13
Game Code Library
Рет қаралды 68 М.
I made maps that show time instead of space
10:44
Václav Volhejn
Рет қаралды 1 МЛН
Unity 2D Platformer Tutorial 11 - Jumping with Ground Check
16:44
2 Ways to do a Ground Check | Unity 2D Platformer Tutorial #2
9:28
MoreBBlakeyyy
Рет қаралды 26 М.
Unity 2D Platformer Player Controller - Double Jump
10:53
Charger Games
Рет қаралды 13 М.
6 Years of Learning Game Development
17:20
Cobra Code
Рет қаралды 278 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН