Unity 2D Platformer for Complete Beginners - #3 WALL JUMPING

  Рет қаралды 166,318

Pandemonium

Pandemonium

Күн бұрын

In this video we're gonna implement wall jumping for our 2D platformer.
➤ Complete project: github.com/nickbota/Unity-Pla...
Subscribe and turn on the notifications if you don't want to miss the fourth episode!
➤ Discord : / discord
➤ Patreon: www.patreon.com/pandemonium_g...
➤ Instagram: / pandemonium_games
➤ Twitter: / pandemoniumnick
➤ Itch: nickbota.itch.io/
#pandemonium #unity2dplatformer #unitycompletebeginner
Tags: Unity 2D Platformer for Complete Beginners,unity complete beginner,unity complete beginner tutorial,unity 2020 complete beginner tutorial,Unity 2D player movement 2020,unity 2d platformer tutorial 2020,unity platformer complete beginner,unity sprite animation,platformer for complete beginners,unity wall jump,unity wall jumping,wall jumping,wall jumping platformer,Unity 2D Platformer episode 3,unity for complete beginners,unity 2d platformer,unity fireball
0:00 Intro
0:05 Cleaning up the code
0:51 Raycast & boxcast
3:10 Implementing boxcasting
4:10 Layers & layerMasks
6:35 Detecting wall collision
8:45 Sticking to walls
10:40 Climbing walls
15:21 Jumping Away from the wall
16:56 Final Result & Outro

Пікірлер: 500
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Just launched episode 4: kzbin.info/www/bejne/hobTdGdqhptnsLs FAQ: 1. I don't recommend skipping this episode, there's some code here that we are going to use later on. If you don't want wall climbing just don't mark any objects with the Wall layer.
@kastordark___
@kastordark___ 2 жыл бұрын
4:54 i am getting error here that Assets\scripts\PlayerMovement.cs(35,38):error CS1503: Argument 2: cannot convert from 'method group' to 'bool' plz tell me how to solve plz plz plz @Pandemonium Games sir plz plz plz
@loginlew
@loginlew 2 жыл бұрын
@@kastordark___ same problem :( here is my code: using UnityEngine; public class PlayerMovement : MonoBehaviour { [SerializeField] private float speed; [SerializeField] private LayerMask groundLayer; private Rigidbody2D body; private Animator anim; private BoxCollider2D boxCollider; private void Awake() { //Grab refrences for rigidbody and animator from object body = GetComponent(); anim = GetComponent(); boxCollider = GetComponent (); } private void Update() { float horizontalinput = Input.GetAxis("Horizontal"); body.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, body.velocity.y); //Flips Player When Moving Left Or Right if (horizontalinput > 0.01f) transform.localScale = Vector3.one; else if (horizontalinput < 0.01f) transform.localScale = new Vector3(-1, 1, 1); if (Input.GetKey(KeyCode.Space) && isGrounded()) body.velocity = new Vector2(body.velocity.x, speed); //Set animator parameters anim.SetBool("run", horizontalinput != 0); anim.SetBool("grounded", isGrounded); } private void Jump() { body.velocity = new Vector2(body.velocity.x, speed); grounded = false; } private void onCollisionEnter2D(Collision2D collision) { } private bool isGrounded() { RayCastHit2D raycastHit = Physics2D.Boxcast(boxCollider.bounds.center, boxCollider.bounds.size, 0, Vector2.down, 0.1f, groundlayer); return false; }
@JoelAguilarCerna
@JoelAguilarCerna 2 жыл бұрын
Thanks a lot man! I'm getting an unexpected behavior, could you please help me?
@HyperGaming-uz1eo
@HyperGaming-uz1eo 2 жыл бұрын
@@loginlew have you found a fix yet?
@Hamza.990
@Hamza.990 2 жыл бұрын
someone help it saysThe name 'boxCollider' does not exist in the current context
@benchew2382
@benchew2382 Жыл бұрын
One of the better tutorials on KZbin! While other youtubers just type code and expect you to already understand what it does, Pandemonium actually explains in detail each and every line of code!
@thenacho6354
@thenacho6354 2 жыл бұрын
even though I don't plan on adding wall jumping to my game, this is still, by far the best player movement tutorial I've seen!
@astronautboi8431
@astronautboi8431 Жыл бұрын
I swear this is literally the only thing i've needed so far, i've tried tutorials in the past, however i found they never worked, or were very unoptimized. This tutorial is god tier.
@hellsgate700
@hellsgate700 Жыл бұрын
If your player is only moving up the wall instead of jumping off of it, remove this line in your update function: body.velocity = new Vector2(horizontalInput * speed, body.velocity.y); At 0:10 it's line 19 in the video
@aapin3348
@aapin3348 Жыл бұрын
Bro I wish I saw this before I removed my wallJumpCooldown. I thought that was the issue so now wall jumping works when you press space on a wall but there is no cooldown lol
@tommyholmberg8961
@tommyholmberg8961 4 ай бұрын
well, hats off and thank you!
@arunadisesh1715
@arunadisesh1715 3 ай бұрын
Thank you this fixed it for me.
@soularpowergaming
@soularpowergaming 2 жыл бұрын
Great video. I had an issue where my player was flying and posted a comment here, but editing it to say that I somehow missed that the isGrounded should get the `collider` property and check for null, not the raycastHit itself.
@naejimba
@naejimba 2 жыл бұрын
This is a great tutorial! I made it all the way so far, and I'm even at the point where I'm changing some things to see what I like (a good way to tell if you understand).
@hisyamhasbi8257
@hisyamhasbi8257 2 жыл бұрын
Keep doing what ur doing my dude! the grind will pay off
@Davieu101
@Davieu101 3 жыл бұрын
Great stuff man. Thank you for delivering great content. Really to the point and your explanations are super helpful.
@user-bx6th4bs8x
@user-bx6th4bs8x 3 жыл бұрын
the quality of these vids is amazing! u put so much effort in this tutorial for FREEE! thx bro
@jaredbush1866
@jaredbush1866 2 жыл бұрын
Just found your Unity 2D videos. Super informative series, thank you!
@kiflisajtos7552
@kiflisajtos7552 3 жыл бұрын
I really enjoy the series and its very helpful. I can't wait for the 4th episode.
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
it's out now
@tonyaldrich1564
@tonyaldrich1564 11 ай бұрын
I'm really glad I kept a backup of my code before starting this. I don't want wall jumping, but figured "I'll follow this for the new jump method, and just get rid of the wall jumping later". The only thing I managed to do was make my jumping worse and break the animation. I even downloaded his code file and copied it into my game. Same thing. I don't know how I messed it up. I know I did a few things differently cause I knew easier ways from other tutorials (like just using "public" instead of "serialized field") The only thing I actually need is a way to stop sticking to walls (I was sticking to walls by just moving sideways and colliding with them in midair) before doing this tutorial.
@majinjamie971
@majinjamie971 2 жыл бұрын
Just finished this one, such well made videos!
@ashwinwilly9746
@ashwinwilly9746 2 жыл бұрын
Great tutorial really helped me! Keep up the good work
@jjkilpi
@jjkilpi Жыл бұрын
Now I found Tube's best tutorial. In the first episode, the texts that really came in handy. There has been insane work in them. Pandemoniun has given his all to the free side. All the other professionals at Tube have deliberately made mistakes that are capable of selling a $ 1,000 package, that is a robbery. I have been trying for seven months to get one tutorial to the finish. I've always been stuck. I got stuck in this tutorial 3 because I got some problem with [serializ ...]. I copied the code that Pandemonium had shared with us and got to continue again. This will be the first tutorial I will complete and I will give the Pandemonium an award. Thank you for a very good job. I wish there were more like you.
@canwegetto1ksubswithnovide421
@canwegetto1ksubswithnovide421 Жыл бұрын
Thanks For The Tutorial I Can Learn Unity So Easley With These Tutorials Keep It Up!
@chartom1700
@chartom1700 2 жыл бұрын
this guy needs more views and his channel is very underrated :)
@Geckotr
@Geckotr 2 жыл бұрын
how the hell you have so few subscribers? This is the best tutorial about 2d platformers i have seen so far and i i have checked a lot of them including unity's official courses, Brackeys, Code Monkey etc.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Thank you! I don't have a lot of videos yet, this is the first series I have for now, but the channel is growing pretty quickly lately and I think it will grow even quicker once I start posting more good stuff.
@Geckotr
@Geckotr 2 жыл бұрын
@@PandemoniumGameDev i guess it's a new channel that's why. Keep more tutorials comin, i'm sure you'll have an explosion of subscribers!
@heypikachu276
@heypikachu276 Жыл бұрын
Solution for people who don't want wall jumping: For anybody having issues with buggy wall jumping: The character's hitbox sometimes gets confused I think and you can wall jump just by touching a surface. The easiest way to fix this is to change the "isGrounded" function from checking using raycasting to checking using Y velocity. Inside the isGrounded function, replace all the code with this: if (body.velocity.y == 0) return true; else return false; That allows the player to ONLY jump when they aren't falling.
@jezozwierz7608
@jezozwierz7608 2 жыл бұрын
This is the best platformer tutorial for a beginner by far!
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Thanks, means a lot to hear that!
@cwithc4968
@cwithc4968 Жыл бұрын
Great really well made videos, thank you for this!
@B-128-Supreme
@B-128-Supreme 2 жыл бұрын
This was very helpful
@AA-co8zd
@AA-co8zd 2 ай бұрын
ı really got a insight about C# codes with this tutorial well explained thank u
@ratala321
@ratala321 Жыл бұрын
I was also wondering why the wall jump isn't working if the statement : body.velocity = new Vector2 (horizontalInput*speed, body.velocity.y); is after the if() for jumping [still inside the big if (wallJumpCoolDown > 0.2f) ] The changes happen around 11:20. Thank you again for the tutorial, I'm glad to be able to learn with you !!
@TheBighi
@TheBighi Жыл бұрын
THANK GOD U PUT THE 3 EPISODE FULL THING IN THE DESC CUZ MY UNITY CRASHED AND ALL OF MY WORK GOT LOST
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
Pleasure, all episodes going forward will have a GitHub project available for download.
@mine_boss1112
@mine_boss1112 3 жыл бұрын
i am starting my unity adventure whit this videos :D
@mxtrem3
@mxtrem3 2 жыл бұрын
"So let's dive right in" This is how you know this guy is legit
@DarkLynxDEV
@DarkLynxDEV Жыл бұрын
For anyone that doesn't want to have to change the gravity scale in both the code and the editor when the player leaves the wall. - Create a float variable called initialGravity (or anything you like) - In the awake, set initialGravity = body.gravityScale - Set the gravity in the else statement, when you de-attach from the wall, to the variable initialGravity :)
@StigDesign
@StigDesign 3 жыл бұрын
Really good Sketch :D :D
@yugbhagat6531
@yugbhagat6531 3 жыл бұрын
Awesome!!!..since this is a series ..it would be cool if you give recap of the previous episode (just a suggestion) :)
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Great idea actually, thanks.
@yugbhagat6531
@yugbhagat6531 3 жыл бұрын
@@PandemoniumGameDev 😊
@scoop9551
@scoop9551 Жыл бұрын
hey @Pandemonium, you are really doing a nice job wow ! I was wondering, do you think you will teach the new input system for unity ? the state one
@thatonerealguy69
@thatonerealguy69 2 жыл бұрын
Amazing outro, very Creative!!!
@turtlegod1013
@turtlegod1013 8 ай бұрын
In the first episode, the edit text suggested I make a jump variable to decide how high the character jumps. Is that preferable to changing the gravity scale?
@ThatOneRobloxDev
@ThatOneRobloxDev Жыл бұрын
also you can add a wall jump and hold animation, just to make it nicer. (pretty ez ngl)
@oskolotlol955
@oskolotlol955 Жыл бұрын
underated deserving more subskriber
@eden7891
@eden7891 2 жыл бұрын
thank you men.!!!!
@subharanjanghoshal5597
@subharanjanghoshal5597 2 жыл бұрын
Super like once again 👍🏼👍🏼👍🏼👍🏼👍🏼 I'm loving the way you're explaining stuff sometimes with special texts, sometimes by opening the documentation page and etc. Thanks a million for your effort ❤❤❤
@eeduuxxx
@eeduuxxx 2 жыл бұрын
Nice tutorial!
@nightfox4013
@nightfox4013 Жыл бұрын
hippety hoppety, your code is now my property. no seriously thanks for putting out a great tutorial like this
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
I don't mind at all :D glad to help, make sure to check GitHub if you run into any issues
@mrsworder
@mrsworder 2 жыл бұрын
Hey will be there an tutorial on how to create an animation or an effect for walljumping? maybe after the basic is completed like extra episode on how to upgrade the game!
@aa-ln8gt
@aa-ln8gt 2 жыл бұрын
Are you gonna make a video on how to add a little cooldown thingy to wall jump and normal jump since it feels kinda weird like this when its spammable. Really appreciate t if you do keep up the good work.
@gameprogramming6550
@gameprogramming6550 2 жыл бұрын
nice tutorial !
@rage8673
@rage8673 Ай бұрын
idk why but i didn't need the separate else statement code in 10:05 for releasing back to the ground, my character was not levitating without it and was indeed falling to ground, yet i still added it so that it dosen't cause any random problem further in tutorial, do you think my case is normal?
@BloodCatters
@BloodCatters 2 жыл бұрын
There is something that I did not understand. Why are we using the raycast method instead of the box collider? They seem to do the same thing. What is the advantage of one on another? It seems that we can do the double jump without using raycast. Thanks in advance for your answers.
@copykey
@copykey Жыл бұрын
Thanks for the such detailed tutorial. and I have some questions : What transform.localScale in Jump() actually works? I understand that this code makes player flip when it jumped off the wall(to see opposite direction). But it wasn't. Maybe I misunderstood something...
@ratala321
@ratala321 Жыл бұрын
Hello! I don't understand why the player can't moove if the statement : body.velocity = new Vector2 (horizontalInput*speed, body.velocity.y); isn't in the statement : if (walljumpCoolDown > 0.2f). The code was typed at 09:15. Thank you for the great tutorial!
@hellsgate700
@hellsgate700 Жыл бұрын
If your player's jump animation stops working, I fixed mine by going into the animator's transition from Jump to Idle and enabling has exit time. Also set the transition duration to 0.
@mmstudiogames6270
@mmstudiogames6270 Жыл бұрын
👌
@PucoltNewl
@PucoltNewl Жыл бұрын
Hi! First of all, thanks for the tutorial! I appreciate it! Its really helpful! ^^ Secondly, ive got my code working, but when i grab a wall on the left side, and i want to jump to the right, it feels very glitchy, and its really hard to make it work. Any idea, how i can improve on that?
@user-sg2cy9rs9w
@user-sg2cy9rs9w 8 ай бұрын
im actually very confused but on my second viewing, i saw myself more as narrator
@Gijs9114
@Gijs9114 2 жыл бұрын
Im not sure whether this bug should be in ''my game'' at this point during this tutorial, but my character can make some sweet front- and backflips when jumping around menacingly.
@Gijs9114
@Gijs9114 2 жыл бұрын
but i seemed to have fixed it by adding Freeze rotation constraint on the Rigidbody of the player
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@Gijs9114 ​ Yeah that's the solution, but hey, if you like them, you can try to leave them in :D
@Gijs9114
@Gijs9114 2 жыл бұрын
​@@PandemoniumGameDev nah 2D super monkey ball ain't my jive :P
@user-lr2cg2st1j
@user-lr2cg2st1j 2 жыл бұрын
I am like #1000. Helpful video!
@haydenjon1143
@haydenjon1143 Жыл бұрын
Hi there, thanks so much for the tutorial. I was wondering if you could help me please. For some reason, when I wall jump, the player floats straight up for a few seconds, no matter what I set the vertical jump amount to. Thanks for any help
@ADEEGANTENGG
@ADEEGANTENGG 2 жыл бұрын
Thanks
@arjotto
@arjotto 3 жыл бұрын
Episode 4 pls LETSS GOO
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
out now
@pythonwithdp8373
@pythonwithdp8373 3 жыл бұрын
Amazing videos
@seymour69
@seymour69 Жыл бұрын
What should I do if I want to remove wall jumping. I've tried removing parts of the script but cannot get it to work.
@lucaverde126
@lucaverde126 Ай бұрын
Im having issues where when adding the last line shown in this video, the player stops flipping on the x axis, any tips?
@LRXM4N
@LRXM4N 7 ай бұрын
Hello, instead of wall jumping, my character climbs repeatedly like a sniper rifle. What should I do ? Can you help me if I send a video from Discord?
@jackpelon9852
@jackpelon9852 2 жыл бұрын
Hello, @Pandemonium, I really liked your tutorials and I am very grateful for it. Could you help me to make the jump adjustable, that is, make a higher jump if I keep the spacebar button pressed and if I just hold down the spacebar button, the player jumps at a lower height. Thank you for your patience and for sharing your knowledge... see you...
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Hey there, the next episode is scheduled for tomorrow and has exactly what you need.
@Hidepls
@Hidepls 2 жыл бұрын
Hi, do you know why my character lost his jumping animation when I did the part with the sticking to walls, I am so confused, the issue is in code I guess, here s the code: using UnityEngine; public class PlayerMovement : MonoBehaviour { [SerializeField] private float speed; [SerializeField] private LayerMask groundLayer; [SerializeField] private LayerMask wallLayer; private Rigidbody2D body; private Animator anim; private BoxCollider2D boxCollider; private float wallJumpCooldown; private void Awake() { // referencie pre rigidbody a animator aka animaciu body = GetComponent(); anim = GetComponent(); boxCollider = GetComponent(); } private void Update() { float horizontalInput = Input.GetAxis("Horizontal"); body.velocity = new Vector2(horizontalInput * speed, body.velocity.y); // otoci nam to hraca if (horizontalInput > 0.01f) transform.localScale = new Vector3(2, 2, 1); else if (horizontalInput < -0.01f) transform.localScale = new Vector3(-2, 2, 1); if (Input.GetKey(KeyCode.Space)) body.velocity = new Vector2(body.velocity.x, speed); // jump shit ... if (Input.GetKey(KeyCode.Space) && isGrounded()) // ... Jump(); //set animator parametre anim.SetBool("run", horizontalInput != 0); anim.SetBool("grounded", isGrounded()); // wall jump logic false true if(wallJumpCooldown < 0.2f) { if (Input.GetKey(KeyCode.Space) && isGrounded()) Jump(); body.velocity = new Vector2(horizontalInput * speed, body.velocity.y); if(onwall() && !isGrounded()) { body.gravityScale = 0; body.velocity = Vector2.zero; } else body.gravityScale = 3; } else wallJumpCooldown += Time.deltaTime; } private void Jump() { body.velocity = new Vector2(body.velocity.x, speed); anim.SetTrigger("jump"); //grounded = false; } private void OnCollisionEnter2D(Collision2D collision) { //if(collision.gameObject.tag == "Ground") // grounded = true; } private bool isGrounded() { // ako keby vystreli lazer k objektu a zisti jeho hodnoty true fasle ked narazi na colider raycats RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, Vector2.down, 0.1f, groundLayer); return raycastHit.collider != null; } private bool onwall() { RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, new Vector2(transform.localScale.x, 0), 0.1f, wallLayer); return raycastHit.collider != null; } } thanks for every tips
@galvano6045
@galvano6045 Жыл бұрын
May i ask you did you go to university in order to learn all of these parts of Unity or its a self-taught lessons from online?
@kutayz7516
@kutayz7516 Жыл бұрын
Hello ! I have a small question. I want to make my character start on the ground at the very beginning of my game but as isGrounded() is not a boolean, I couldn't make it "true" at the beginning. How can I fix this? Thanks so much.
@kdglol2914
@kdglol2914 2 жыл бұрын
I have this problem where if I cling on the left/right wall and then press the opposite key, the sprite flips, and then there is a delay before it starts moving again, do you know how to fix this?
@teodorspeksens9135
@teodorspeksens9135 2 жыл бұрын
I was wondering, when I hold down the jump button, for me it''s W, my character just jumps forever, how do I set my character to jump only once even if I'm holding down W?
@themeltedmonki7897
@themeltedmonki7897 Жыл бұрын
@Pandemonium, how do I fix this error: The modifier "private" is not valid for this item
@rajatmusale1948
@rajatmusale1948 2 жыл бұрын
Hey, follow-up query: even at the end of the tutorial my character stays stuck to the wall unless I specifically hit SPACE or use the arrow keys/A/D keys. It doesn't fall down on its own when on the wall. Do you think it could be an animation issue? I even copied your code to a new file and tested it out to see if it was a coding error on my side.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
That's how it's supposed to work. Were you expecting it to slide down?
@rajatmusale1948
@rajatmusale1948 2 жыл бұрын
@@PandemoniumGameDev Yes, I was. I mean, we did put in gravity as a parameter to the rigidbody, so I thought it might slide down automatically once it hits the wall.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@rajatmusale1948 Nope, the gravity applies to the time when you are not on the wall. For the wall scenario we wrote body.gravityScale = 0; try changing the 0 value to something else and you should get the sliding to work.
@YuriRVG
@YuriRVG 20 күн бұрын
My player jumps at different height, sometimes flying away from a screen; I tried add vector to vertical velocity, change force methods, change GetKey for GetKeyDown. With some of them it feels better sometimes but then he again jump to the space;
@qaerkyr9197
@qaerkyr9197 Жыл бұрын
My player gets stuck once he falls on on the ground. Left and right is not working. Only jumping it works. Any idea why? Found it looks like when defining the player rigid body we can have problems with walljump code part from update method.
@rosellewaccent
@rosellewaccent Жыл бұрын
when you copied and pasted at 6:40 the row number skipped one number. meaning the new private bool starts at row 53, when I do it, it starts at row 54, how do you make rows that skip numbers? if you get what I mean
@Philip-qq7ql
@Philip-qq7ql Жыл бұрын
Hi i dont know if you are still replying to comments but the tag "Grounded" doesnt appear in the Ground layer variable
@TheCrabActivist4525
@TheCrabActivist4525 2 жыл бұрын
You are my favorite coding youtuber! Because you actually bother explaining things and you've got a fun sense of humor. Stay safe my dude.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Thank you! I'm not sure I'd agree about the sense of humor though :D
@TheCrabActivist4525
@TheCrabActivist4525 2 жыл бұрын
@@PandemoniumGameDev It's a little humor and the fact that you can tell that you enjoy what you're doing.
@lukspie
@lukspie Жыл бұрын
Hi there, I have a question.. My player isnt getting pushed away from a wall.. I didn't find any issue in code nor in the unity itself.. any ideas?
@SpArkyTheDerg
@SpArkyTheDerg 4 күн бұрын
4:56 the groundlayer thing doesnt show up in the script on the right. Also even though our code is exactly the same, letter for letter, the player gets HUGE, is always in the jumping animation, and cant jump or wall jump at all.
@DragonPox90210
@DragonPox90210 2 жыл бұрын
Just started following along to your videos (amazing stuff by the way!) I'm finding an issue that after deleting "float" from the horizontalInput line suddenly I can't move or jump anymore any help would be appreciated
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
I think you didn't create a new variable for it so it's giving you an error but I need to see your code and your console to be sure.
@DragonPox90210
@DragonPox90210 2 жыл бұрын
@@PandemoniumGameDev I went back and rewatched the video- turns out I missed a line when typing things out, it works perfect now
@MadManPetr1
@MadManPetr1 Жыл бұрын
I need a little help please. I just wanted to make animation of wall jump animation. But I didnt manage to do that. In the animator I think its fine, I just dont know what to put into my parameter anim.SetTrigger("onWall", ). I put anim.SetBool("onWall", onWall() && !isGrounded()); but that did not work for me. Please help if you can, Thanks.
@sophiesun3634
@sophiesun3634 2 жыл бұрын
Hi there, this is a super fun tutorial. I only have one issue that my player is behind the wall when doing the wall jumping. Any insight of how to fix this would be greatly appreciated.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Will need a video to understand the issue. Mind sending it on Discord?
@Hypcros
@Hypcros 2 жыл бұрын
Guessing this is too late but if other people have this problem then make sure to set your players order in layer to 1 or a value greater than the wall. This can be found by going to Player>Sprite Renderer>Additional Settings>Order in Layer.
@vietanh3521
@vietanh3521 Жыл бұрын
hey uh, i have some issues please help. Sometimes when i jump onto the walls i stick to them, even when i press A or D to go to the opposite direction, i still can't get off the wall. I've tried to fix but i couldn't get it right. :((
@kostasalexakhs2271
@kostasalexakhs2271 2 жыл бұрын
Hey. I hope that u still keep replying comments. When im at the top of wall and im touching ground, if i slip of the edge with out jumping my Player is stuck to the down wall but he is with the Running Animation. Any advice? thank you ❤
@theduck1539
@theduck1539 2 жыл бұрын
idk if you saw the comment so Im just reposting it I ran into another issue were the code for the wall jumping does work It just climbs up walls and when you go the right there barley any force here's the code I don't understand since I feel like I did everything right using UnityEngine; public class PlayerMovement : MonoBehaviour { [SerializeField] private float speed; [SerializeField] private float jumpPower; [SerializeField] private LayerMask groundLayer; [SerializeField] private LayerMask wallLayer; private Rigidbody2D body; private Animator Anim; private BoxCollider2D boxCollider; private float wallJumpCooldown; private float HorizontalInput; private void Awake() { //Grab refrences for rigid body and animator from object body = GetComponent(); Anim = GetComponent(); boxCollider = GetComponent(); } private void Update() { HorizontalInput = Input.GetAxis("Horizontal"); //Flip player when moving left or right if(HorizontalInput > 0.01f) transform.localScale = Vector3.one; else if(HorizontalInput < -0.01f) transform.localScale = new Vector3(-1, 1, 1); //Set animator parameters Anim.SetBool("Run", HorizontalInput != 0); Anim.SetBool("grounded", isGrounded()); //Wall Jump logic if(wallJumpCooldown < 0.2f) { body.velocity = new Vector2(HorizontalInput * speed, body.velocity.y); if(onWall() && !isGrounded()) { body.gravityScale = 0; body.velocity = Vector2.zero; } else body.gravityScale = 7; if (Input.GetKey(KeyCode.Space)) Jump(); } else wallJumpCooldown += Time.deltaTime; } private void Jump() { if(isGrounded()) { body.velocity = new Vector2(body.velocity.x, jumpPower); Anim.SetTrigger("jump"); } else if (onWall() && !isGrounded()) { if(HorizontalInput == 0) { body.velocity = new Vector2(-Mathf.Sign(transform.localScale.x) * 10, 0); transform.localScale = new Vector3(-Mathf.Sign(transform.localScale.x), transform.localScale.y, transform.localScale.z); } else body.velocity = new Vector2(-Mathf.Sign(transform.localScale.x) * 3, 6); wallJumpCooldown = 0; } } private void OnCollisionEnter2D(Collision2D collision) { } private bool isGrounded() { RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, Vector2.down, 0.1f, groundLayer); return raycastHit.collider != null; } private bool onWall() { RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, new Vector2(transform.localScale.x, 0), 0.1f, wallLayer); return raycastHit.collider != null; } }
@user-jn9tt3ry6k
@user-jn9tt3ry6k 6 ай бұрын
hi hope you can answer bc i cant use the line: "return raycast.collider = null;" idk why... it shows that the mistake is at raycast.collider but idk how to fix it
@user-jn9tt3ry6k
@user-jn9tt3ry6k 6 ай бұрын
nvm i just didnt do "!=" cuz im DUMB
@cleve3731
@cleve3731 Жыл бұрын
Bro so what do i do when the Wall object and Fireball object disappear ? Im sure I saved and I closed Unity, opening it and saw that those two object were gone ?
@nikbo526
@nikbo526 7 ай бұрын
whats your extensions
@ds1jmadx5
@ds1jmadx5 Жыл бұрын
Hi, for some reason the wall jump only works on one side of a wall, is that intentional or did i do something wrong?
@spectorx185
@spectorx185 9 ай бұрын
for some reason every time I try to do the wall jump thing my character just sticks to the walls and refuses to come off, even when I press A,D or any of the arrows. Can someone tell me what I've done wrong.
@Royal_IndianGuy
@Royal_IndianGuy 9 ай бұрын
idk what happened, but all was working until i added something that he said about the wall jump cooldown, but after i wrote the code, and when I checked the result, the player was only doing its run animations, but wasn't moving anywhere, before that one piece of code tho, everything was working fine... Can somebody pls help me with my problem?
@freshballs1458
@freshballs1458 2 жыл бұрын
after completing at 6:07 my charakter wont jump, why is that so?
@shenhall124
@shenhall124 Жыл бұрын
I have 1 error that is: when holding down the Space button, it keeps flying up forever? What to do now
@dogged2099
@dogged2099 3 жыл бұрын
Hey, if you're still replying to comments on this video, after adding the code from the jumping away from the wall segment, my character can jump a little bit in the air and I also can't jump whilst on the wall still. Any idea of how I can fix this?
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Will need to see a video to understand the issue. DM me on discord
@aklndakalmasn5760
@aklndakalmasn5760 2 жыл бұрын
​@@PandemoniumGameDev​ Same problem. If you know solution. Im waiting for it. Edit: Almost fixed. Just jumping a little bit on the wall.
@b7lee948
@b7lee948 2 жыл бұрын
how can i add animations like wall grab? also my jumping became infinite
@hunterx4583
@hunterx4583 2 жыл бұрын
Need help 1. When i long press the space bar the player jumps backwards infinitly. 2. When i double press the space bar the player jumps backwards. P.s. Great video and explanation btw.
@adeelbashir824
@adeelbashir824 Жыл бұрын
My player is not playing jump animation sometimes after implementing the new jump system.
@m1di797
@m1di797 Жыл бұрын
3:24 (just a timestamp i'm keeping for myself)
@r3dh00d6
@r3dh00d6 9 ай бұрын
Hello, I got a problem. even though I follow the script that little Ground Layer under speed isn t there. Any thoughts?
@PandemoniumGameDev
@PandemoniumGameDev 9 ай бұрын
Yeah, you need to create it first, check out 5:10
@anthonylewis3804
@anthonylewis3804 Жыл бұрын
I'm having a problem when my I hold the W key the player rapidly jumps up the wall(pls help)
@stormy2049
@stormy2049 Жыл бұрын
What do I do if I want the Mathf thing to return more than 1 or -1?
@overlydedicated2794
@overlydedicated2794 2 жыл бұрын
What does the wallJumpCooldown do exactly? I'm having a hard time visualizing it. Mostly the part of the code that says "if (wallJumpCooldown > 0.2f)" and the other part that says "wallJumpCooldown += Time.deltaTime;"
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
It's a timer that prevents you to do wall jumps infinitely so we check if 0.2 seconds have passed since the last wall jump before allowing the player to do another one. If we don't use this you would be able to just fly up the wall, try replacing 0.2f with 0 and you'll see.
@hisyamhasbi8257
@hisyamhasbi8257 2 жыл бұрын
@@PandemoniumGameDev i also have a hard time understanding this one, how does the code know that the value is a cooldown? which line is for the countdown from 0.2 to 0?
@overlydedicated2794
@overlydedicated2794 2 жыл бұрын
@@PandemoniumGameDev Hi, I took a break from learning because of other things, and now I'm back. Anyways, I'm still confused about wallJumpCooldown. I see that it's been initalized in that class's field but it it not declared anywhere in the code with an explicit value. So, how is does wallJumpCooldown > 0.2f true when we don't even assign a value to wallJumpCooldown?
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@overlydedicated2794 wallJumpCooldown starts of at a value o 0 when you start the game. Then we increase it during every frame by using this line: wallJumpCooldown += Time.deltaTime; So basically wallJumpCooldown is a timer. Now every time you perform a wall jump wallJumpCooldown becomes 0, and we use wallJumpCooldown > 0.2f to make sure that 0.2 seconds have passed before we allow the player to perform another wall jump. Does this help?
@overlydedicated2794
@overlydedicated2794 2 жыл бұрын
@@PandemoniumGameDev @Pandemonium Ok. Now I understand. I didn't know it started with a default value of 0. Thank you for the explanation. 😁
@stingycarrot7683
@stingycarrot7683 Жыл бұрын
Hey man just a question, at 8:40 when the console is showing the true or false detection, my console is spamming true or false for each millisecond and i have 999+ console alerts within a second of pressing play, what would be causing mine to spam like that and how could i go about solving it? Cheers
@thero2127
@thero2127 Жыл бұрын
press the collapse button (also the detection is just for testing you can delete it)
@fry7746
@fry7746 Жыл бұрын
10:35 My player is sticking to the wall even when I press the right arrow which should make it stop sticking. I think that it's related to the collision detection, since I had to use a capsule collider and the collision detection isn't working perfectly. (I have to use a capsule collider since my player was sticking to the ground)
@bahajirutmspt436
@bahajirutmspt436 Жыл бұрын
A bit late but I set the edge radius of the box colliders(on my walls, not the character) to a very small number like 0.025 and it seems to solve the issue. Dont know if adding edge radius to character solves the problem. Also for anyone who needs it. If your character start spinning while moving you can tick "lock rotation, z" option under rigidbody/constraints for the character
@cBrnnn
@cBrnnn Жыл бұрын
At 9:14 he cuts the line " body.velocity = new Vector2(horizontalInput * speed, body.velocity.y); " from the start of the update method to enclosed within an if statement. I had that line twice since I didn't notice it was cut and it prevents the clean push off the wall from happening when climbing. Putting this here for any future people who also get confused :)
@raswaking8172
@raswaking8172 Жыл бұрын
@@cBrnnn thank youuuu!! I had lots of problems because of that
@memosickduck9230
@memosickduck9230 Жыл бұрын
Please tell me, what is WallJumpCooldown float used for?? I don't understand..
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
It's basically a timer that doesn't allow the player to wall jump immediately. So if you do one wall jump you need to wait 0.2 seconds before being able to do the second one. WallJumpCooldown is the timer that keeps track of how much time has passed since the last wall jump.
@memosickduck9230
@memosickduck9230 Жыл бұрын
@@PandemoniumGameDev Thank you very much, Sir..
Unity 2D Platformer for Complete Beginners - #4 SHOOTING
17:25
Pandemonium
Рет қаралды 165 М.
Unity 2D Platformer for Complete Beginners - #2 ANIMATION
21:35
Pandemonium
Рет қаралды 288 М.
Самый большой бутер в столовке! @krus-kos
00:42
Кушать Хочу
Рет қаралды 6 МЛН
MINHA IRMÃ MALVADA CONTRA O GADGET DE TREM DE DOMINÓ 😡 #ferramenta
00:40
GADGETS VS HACKS || Random Useful Tools For your child #hacks #gadgets
00:35
Mac & Cheese Donut @patrickzeinali @ChefRush
00:53
albert_cancook
Рет қаралды 216 МЛН
Improve your Platformer’s Jump (and Wall Jump) | Unity
8:12
Unity 2D Platformer for Complete Beginners - #1 PLAYER MOVEMENT
15:38
How to Start Gamedev in 2024
10:28
Sasquatch B Studios
Рет қаралды 298 М.
The Most HILARIOUS FAKE Minecraft Speedruns EVER...
16:39
Ayundaru
Рет қаралды 118 М.
How To Wall Slide & Wall Jump In Unity
6:38
bendux
Рет қаралды 61 М.
Unity 2D Platformer for Complete Beginners - #7 HEALTH SYSTEM
23:17
Что творит этот боец
0:59
Garga
Рет қаралды 1,4 МЛН
Я просто стоял афк...
0:40
Nikolka
Рет қаралды 2,4 МЛН
Не покупай эти гиперзаряды 👎
0:36
Bubs
Рет қаралды 1,3 МЛН