How To Wall Slide & Wall Jump In Unity
HTML-код
- Опубликовано: 2 фев 2025
- Learn how to add wall sliding and wall jumping to your game 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
Get Back by Silent Partner
Midnight Special by E's Jammy Jams
Dude you have literally help me build out the base of my character movement. You deserve WAY more subscribers than you currently have
Definitely
Found your channel today, it's gold. I wanted to make my own platformer, and I saw that you have the tutorials I'm looking for - coyote time, dash etc. Thank you!
A couple more videos and I can make celeste with my own hands. Thank you, friend!)
I know I'm not bendux, but..good on you!Wish you luck!
im actualy making a celeste clone with this code lol
I hope you continue to make videos! Your tutorials are amazing and very easy to follow!
YES!
A year after posting and this is still super helpful ( especially for people just getting back into game development! ) Thanks for making this :)
Stumbled across this tutorial while making a game for Game Jam... Once i saw your code structure i doubted everything i knew after 6 months of self-learning. I basiclly deleted my code, wrote down same as you use, tweaked a little bit to work as i initially planned and OH MY GOD now everything is working smoothly, code is readable and has any kind of structure to it. Great tutorial !
yeah honestly self-learning is good but it's alvays good to watch a tutorial once in a while dx
What a simple and clear tutorial. Thanks for this ! It helps me a lot on my project !
Great video! Could you do a tutorial about spawning entities (like enemies) outside of players vision for your next video? It would greatly help me.
Also, abolute respect for replying to new comments on your videos! You are one of the best unity tutorial youtubers and it's criminal you don't have more subscribers
I've added it to my list. Thank you for the suggestion!
@@bendux Thanks for a quick reply! I love when creators are in touch with ther viewers
Dank deinen Videos hab ich einfach das Grundgerüst für ein coolen 2D platformer/runner in nur 7 std geschaffen. Du machst die Videos und Scripts so simpel und easy zu verstehen... Eif der King aller Programmierer.
Vorschlag für ein neues Video (Zwar nicht wirklich in deinem Stil aber ich hab trzdm Hoffnung) : Wie man das Grundgerüst für ein RTS 2D Spiel wie Supremacy macht.
I've added it to my list. Thank you for the suggestion!
@@bendux You are amazing!
Clean code, detailed explanation, great demo! All in all awesome video!
GRAPPLING HOOK NEXT PLZ also great content you get straight to the point and are clear about how these functions work also please keep uploading
Straight To The Point. You're The Best 2D Game Tutorial Maker On RUclips. Keep It Up! Ur Aweasome
At first some stuff may fail, but once you start reading and remembering what you do and see in this tutorials you'll see success at some point
Just found out about your channel and im in love with it already. Really hope you make more vids in the future
I have a few ideas for videos
-How to make a level barrier that teleports you back if you fall. Seems simple, just a modified Teleporter Script
- How to make a 2D simple gun
- Simple 2D enemy
- How to have pickups
I've added them to my list. Thank you for the suggestions!
@@bendux hell yea i will wait
@@BreadAckerman too
@@BreadAckerman language
Great videos, I've been using unity since 2020 and took a year off of it. Just getting back into it, trying to refresh my memory on everything. This was a great tutorial, thanks! I would love it if you could make a video tying in all the movement tricks, such as double jumping, wall jumping, wall sliding, etc. into one neat script. As well as setting up animations for those various actions. Thanks!
I definitely want to upload a character controller with all the features of my tutorials in the future. Thank you!
thanks for those tutorial man, I've followed the 2D movement, dash and this one, and it works perfectly :D !
Your tutorial are incredible, it's helping me so much developing my game, thank you! Keep it up! :)
is there any way to add a kick off the wall so that if you hold the directional input into the wall, you go upwards and away from the wall
Little fun tutorial! Great job :)
Been a while since the video came out but I was curious how to implement double jumping after performing the wall jump. Anyways awesome tutorials!
If u guys are stick in to the wall try creating a 2d physics material and make friction 0 then add it to the material in collider or rigid body component. great tutorial btw thanks.
how to do with 3d character?
@@Hardcore0 sry bro I don't know about 3d. May be it's the same not sure tho.
Thank you so much! I was scrambling with the code to see if I missed something, and was left confused when everything was the exact same as the video.
You've saved me from countless hours of agony haha, thanks.
you are THE GOAT!!!! I was spending a lot of time trying to fix this issue, like a very lot time. I completely forgot there was a friction option, you just made my day sir, thanks o7
@@bucksygaming BROOO THANKS YOUR SO CLUTCHHH
Your tutorials are awesome! Big thanks for them!
How do you not have more subs! Incredible videos!
Thanks! your helped my thesis work. I wish you success too!!
i love u so much, thank u, u have single handed made my game 100x times better with the movement tutorials
tnx bro, u made my day with this vid, i will try it tomorrow
Thanks a lot this really helped me out!
Good vid really useful your vids are so good
He deserves more subs🎉
the matf.clam in sliding is causing the lagging issue so if you don't want it just use constant value
Acabo de encontrar tu canal, espero que sigas haciendo tutoriales, ya me suscribí !!!!
When you upload new unity tut?
And
How to make animated characters from Tuts you uploaded
I want to upload a new tutorial soon, and there will definitely be a video about animations in the future.
Your videos are very useful with me. Thank you very much.
Hey, I was wondering if you could make a tutorial on how to make movement with acceleration. My movement feels very stiff and I want to have it to where if I start holding "D," it takes some time to reach maximum speed. Or when I turn around and instantly start moving the other direction, I want it to take some time.
Try Input.GetAxis instead of Input.GetAxisRaw.
Thank you!
I wish you would combine all of these into one where you can double jump, dash, wall jump, and wall slide.
I definitely want to upload a character controller with all the features of my tutorials in the future.
Can you make a tutorial for adding animations to these?
I definitely want to make a video about animations in the future.
Hey man, thanks for this series of unity 2d videos. They are very helpful to us beginners. I have a question:
In order to have a better and clean coding do you recommend to us to build only a gigantec script with every new hability ? Or is less complicated to create a script for every new skill ? I mean, a script just for walk, another one just for jump, etc etc. And we can manage easily on unity ?
Thank you.
I'm still learning myself but I thought I could give my answer to your question.
I use unity and when I create a script for my player's movement, I usually call it playerMovement and put all player movement inside that script. That includes basic movements using WASD and any jumping for the game. I haven't made a game yet with special abilities for the player but depending on the ability, you could put it in playerMovement or into another script. Something like double jump or dash, I'd probably put into my playerMovement script though.
It isn't hard to manage as long as your code is clean and your variable names are easy to understand.
I hope that helps if you haven't already come to a solution/answer 😊
ty it work but i cant dash now can u help?
It probably has something to do with the order of execution in your script.
Tried your method, but it's not working because of colliders. Basicly, if the player is aganst a wall and "runs" into it, the player stops moving and doesn't fall (y velosity is 0). Your player object seems to not collide with objects in that way, I'm not sure what you did to prevent this.
Create a Physics Material 2D, set the friction to zero, and add it to your player's Rigidbody 2D component.
You have good vids, I like them. And the code is good. Your content is useful to me, even though I am Russian, thank you.👍
Perfect! Thanks a lot bro!
yeni video nerde
I tried your code and the wall slide doesn't work in my case I do not know what could be the issue. Also the wall jump will not apply the horizontal force away from the wall when wall jumping
by any chance is it only on a wall that is to the right of the character?
@@armandasaukscionis2558 both sides unfortunately
Create a Physics Material 2D, set the friction to zero, and add it to your player's Rigidbody 2D component.
@@bendux thanks but I already done that
@@CATaclysmOg I advise you to compare your script with the source code in the description.
I love your videos so much!!!
Thanks brother it helped me out a lot .Can u please make a video abt enemy ai
I've added it to my list. Thank you for the suggestion!
Could you maybe make a tutorial on a top down dash? I've seen your platformer dasv but i can't seem to implement in vertically, could you maybe help me with that please?
You could use a bool and increase the move spped for a short amount of time like 0.2 seconds with an Enumerator like
If(whatever key you want pressed & & candash)
{
StartCoroutine(Dash() ) ;
Candash = false;
}
IEnumerator Dash()
{
Move speed = whatever. Make it high enough;
Yield return new WaitForSeconds(0.25f);
Movespeed = whatever it was before;
Yield return new WaitForSeconds(however long) ;
candash = true;
}
@@Coleslaw333 i'll give it a shot later and let you know if it worked
We have a solution for that on our Discord server. Feel free to join!
Good please create more unity videos
An idea:
A way to tag an object as being able to be wall jump'd on
I get a very sharp jump, almost teleportation - what could be the reason?
Would you like to show me your code on Discord?
@@bendux already, in help
I'm pulling my hair out here, thanks to my terrible spaghetti code. I followed your tutorial(really great btw,) the best I could given my existing code, and whenever the wall jump duration runs out of time, the player just abruptly stops mid air and falls. Any idea on why this is happening? Thanks!
What should happen instead?
@@bendux the wall jump should have continued. I ended up completely rewriting the code, because it was a huge and terrible mess.
@@KatelynCollins225 It's a good idea to refactor your code from time to time.
Thanks mang
I copied the source code and pasted the code into PlayerMovement and made wall thingy. I linked it to the player and everything but when i play if i jump at the wall it just noclips through. I changed the layer to wall for the walls. Help pls
Do your walls have a Box Collider 2D component?
@@bendux Oops. yeah thanks i didnt have it
Thank you for your tutorials! They are amazing! Could you make a tutorial about slopes please?
I've added it to my list. Thank you for the suggestion!
Mr.Bendux, how would you go about implementing roguelike - turn-based movements? The player moves - a monster moves?
The Double Jump and the walljump dont work together, i mean it work but i can jump infinite on the wall. any fixes?
Would you like to show me your code on Discord?
I fixed it! your tutorials are really nice
@@emilian_spielt300 I'm glad you were able to fix it.
@@emilian_spielt300 how did you fix it
Can you maybe show us how to do animations aswell? Your tutorials are super easy to follow
There will definitely be a video about animations in the future. Thank you!
When I tested the sliding mechanic before implementing the jump, it worked perfectly. But after I coded the jumping the wall sliding stopped working for me, do you know of why this could be?
Would you like to show me your code on Discord?
I love these tutorials, although i think it would be nice to learn what is happening, so i can replicate it on my own.
Thanks for the video but one question ? did you use isWallJumping in any condition ? I cant see any.
I even used it twice.
Your tutorials are the best.
But then I am wall sliding and i hold arrow key what makes my player face wall im sliding I can just spam space bar and he just slides upwards all the time sticked to the wall. Is there a way to fix that?
Would you like to show me your code on Discord?
@@bendux ok
@@neilaszemgulys6754 hey i have the same problem, what was the solution ?
couldn't I just reuse the Ground Layer? Or would that cause complications down the line?
Hey, I was able to combine your wall-jumping tutorial and you dash tutorial, and I need a way to make the same thing for player 2, since I need different parameters or something. Any way to fix that?
What's the problem?
Hello, whenever I am sliding on the wall and I frequently press the jump button, I've noticed that the player character jumps vertically along the wall instead of performing the intended action.
There is a link to the source code in the description.
how do i add animations to this script such as Jumping animation wall jumping and running
I definitely want to make a video about animations in the future.
You.Are.Awsome!
Thx for the vid.
I was just wondering, how does the "mathf.clamp" function work?
Like i mean...i know how it works and how to use it with transform.position, but not with rigidbody 😢
I can't find any lessons on it, only with the transform...
docs.unity3d.com/ScriptReference/Mathf.Clamp.html
@@bendux thx, but it still doesn't really make sense...
I don't get how ur using the clamp function in the vid, anyways thank you....
@@UnsupervisedIdiotOfficial What's the problem?
your tutorials are grat but i have managed to make you able to jump when you not on the ground do you have any idea what went wrong ?
You probably set up the layers incorrectly.
@@bendux thanks
This is a great tutorial but for some reason whenever I try to Walljump my character just stickes to the wal for a little bit while in the air and dashing feels more like a jetpack now. Please help...
if (Input.GetButtonDown("Jump") && wallJumpingCounter > 0f)
{
isWallJumping = true;
rb.velocity = new Vector2(wallJumpingDirection * wallJumpingPower.x, wallJumpingPower.y);
wallJumpingCounter = 0f;
i think this line is your problem
Good Job !
i have a question:
why use Mathf.Clamp instead of just fixing it to -wallSlidingSpeed ?
don't use it ,it cause the lagging issue while sliding so just use constant value
i came here after ur dashing tutorial vid (great tutorials btw) and i added walljump into it without touching any of the dash code... for some reason it completely breaks the dash and the walljump/slide just doesn't work whatsoever...
pls help :(
It's hard to tell what's going on without seeing your script.
@@bendux ill try to dm u the script the next time I open my pc... I am out of station rn...
@@Aadarsh-wv7xc There is a link to our Discord server in the description.
K thx
Thank you for the video. For some reason my player starts to slide up when it’s on the top half of the wall and slides down when it’s on the bottom half. I don’t if anyone else is having the same issue.
Would you like to show me your code on Discord?
im new in unity and my dream is to make a platformer. it become reality. big thanks to you for making this short, Obviously, and fun tutorials. and here idea for tutorial: boss fight!!! and maybe make a playlist for this tutorials? its the best tutorials ive ever seen. please, keep doing this mythic tutorials for me, and for everyone else. i just found your channel a few hours ago. youtube, this chnnel need to get a big golden play button. please like this comment to make him see this!!!!!!!!
Hey, I was wondering how I could use acceleration and momentum with the wall jump, as it feels stiff. As soon as the wall jump ends, I can start moving the other direction without speeding up.
Try Input.GetAxis instead of Input.GetAxisRaw.
I don't know why but I did it exactly like in the video and it doesn't work. I try to solve it for 3 hours but it still doesn't work. Maybe it's a bug or something like that, do you have a solution?
nvm i just was dumb
@@Just_Zeni what was your issue?
Great tutorials. Is there an easy way to have a certain animation while sliding down the wall until you hit the ground or jump?
I definitely want to make a video about animations in the future.
Hi how do i make wall jumping an power up.(When you start a game you dont have it but you can find it somewhere in the map and when you can wall jump permanently)
We have a solution for that on our Discord server. Feel free to join!
@@bendux i am already joined
for some reason when i wall jump while facing left i lose all momentum and drop to the ground
Would you like to show me your code on Discord?
the problem with assigning the "wall" layer to the walls is that they will not count as ground if you stand on top of them and therefore you wont count as grounded when on top of a wall. this is no good if the wall is also part of the same object that is a floor.
2:35
This code works great for vertical jumping up walls, but it doesn't seem to be pushing the player off the wall properly. If I have the player sliding down the right hand side of a wall and press jump without holding down a movement direction then they will occasionally get a small bit of movement before resetting their Rigidbody velocity.x back to 0.
In this video are you actively pressing in the direction opposite the wall when you jump off? I think the problem is tied to update refreshing the velocity based on horizontal.
Would you like to show me your code on Discord?
Great Tutorial!!!!!!!!!!!!!!
For some reason the player is sticking to the wall when it should be sliding. There isn't a problem with the wall jumping or anything else. It just sticks to the wall, I even turned the isWallSliding to public for a while so I could see if the sliding script is activating, but it didnť have a problem. Could anyone help me with this? Does it have something to do with friction? I'm a little lost.
Create a Physics Material 2D, set the friction to zero, and add it to your player's Rigidbody 2D component.
@@bendux Thanks that helped me a lot. I also watched some of your other tutorials and they are really good
You are the best!
I do really think i understood the idea between all the code on this video, but my character seems to bounce to the other wall instead of waiting me to press the jump button again. In my project the gravity is lower so i had to change values from the wallJumpingPower variable in orther to make it organic. Why is he bouncing? Did i forget something important on the video? I already watched it 3 times. Thank You!
Would you like to show me your code on Discord?
@@bendux I also tried it and am facing the same problem that it is jumping twice instead of once. Any solution to that?
@@sunhikpramanik2429 Join our Discord server, and let's solve your problem together!
there is one problem, if you go on top of an object with the layer Wall, it won't have the ground layer so everything checking for isGrounded will be bugged, any solutions for that please ?
2:35
do an animation tutorial
I definitely want to make a video about animations in the future.
@@bendux i have tried to do them for like 8 hours now 😅
When i type this line;
if (isWalled() && !grounded() && xInput != 0f)
it says "Non-invocable member 'PlayerMovement.grounded' cannot be used like a method." Can you please help :(
it seems that "grounded" is not a method, its a variable (bool). Just delete brackets
if (isWalled() && !grounded && xInput != 0f)
i used the ground and wall layer as one layer. lets hope it doesnt break anything
Help my character launches much further than its supposed to on the wall jump
Decrease the wallJumpingPower values at the top of the script.
@@bendux I tried lowering it but it ends up launching you at tripple the speed of the default walljumppower no matter how i change it
@@simonstechhacks Would you like to show me your code on Discord?
Can you make a tutorial for walking animation
I definitely want to make a video about animations in the future.
Im confused
When i create empty and play the ground and wall check doesnt stay on the player
The ground check and the wall check must be a child of the player.
I used it in my game and it worked perfectly fine. I turned off my pc and when i opened it again (3 hours later) all of a sudden it doesnt work. Why is that? Can anyone help me?
Very good video Thank u soo much :))
Thanks!
thank you SOoooooooo much, How can I increase my character wall jump ?
Increase the wallJumpingPower values at the top of the script.
hello, I encountered a problem with the flipping part of the character. It seems that when the walljump happens, my character for some reason looks left when moving to the right and vice versa. I followed your tutorials on the movement + this video. Would appreciate the help thanks :>
Would you like to show me your code on Discord?
your player could by rotated to the wrong direction from the beginning. you can flip it in unity by adjusting the scale on the X or do the same in the start method: void Start()
{
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
(Doing it in unity is better :) )
Pls help me fix, mine says that 😢 the wallLayer, wallCheck, and wallSliding is never assigned to and will always have its default value null
You probably forgot to assign the variables in Unity.
I'm so sorry, I'm fliping my player by rotating it on the Y so what do i do when setting the WallJumpDirection ? Thnx
Would you like to show me your code on Discord?
when I jump off the wall the player continues to move any quick fix?
Would you like to show me your code on Discord?
There's a bug that randomly executes when I wall jump consecutively. My player suddenly can't move. It can only jump. I have my own code and I use the new input system. I wrote the code in a different way but it still functions the same.
It's just, when I jump from wall to wall, and the wall slide suddenly gets cancelled (this happens because I use two different layers for the wall, one that you can't do a wall jump and one that you can) as I was saying, when the wall slide suddenly got cancelled after doing multiple wall jumps, I'll just fall to the ground and I can't move from that position.
Edit: The issue became even more clear, the bug only happens when I was holding the horizontal input and the wall sliding was cancelled during that time. And when I fell back to the ground, I can't move unless I do another wall jump.
It's hard to tell what's going on without seeing your script.
@@bendux i realized that this bug only occurs when using the new input system. I can't explain it, it just happens.
@@CodeAikawa Would you like to show me your code on Discord?
can you combine all the videos now?
I definitely want to upload a character controller with all the features of my tutorials in the future.