HOW TO MAKE 2D LADDERS IN UNITY - EASY TUTORIAL
Вставка
- Опубліковано 25 лис 2024
- In this Unity and C# tutorial we will make a simple ladder system !
By the end of the video your player character will be able to climb a ladder (or any other object you may want him to climb for that matter) !
--------------------------------------------------------------------------------------------------
SUPPORT ME : / blackthornprod
------------------------------------------------------------------------------------------------
LINK to the ONE WAY COLLISION PLATFORM : • ONE WAY COLLISION PLAT...
LINK to the 2D PLATFORMER CONTROLLER : • 2D DOUBLE / TRIPLE JUM...
--------------------------------------------------------------------------------------------------
LINK to my TWITTER : / noacalice
LINK to the DISCORD SERVER : / discord
I was struggling with ladders, but this video is short and informative enough for me to follow along. I am now excited to go home and implement!
thank you, im an artist and definitely not a programmer , your videos helped me a lot to build a very simple game-- well, actually not a game, but an avenue where i can showcase and test my animations and created character game assets. Thank you again!
Guys if your ladder is a tilemap DON'T USE COMPOSITE COLLIDER. The raycast will NOT work for a composite collider. I learned it the hard way it took me HOURS.
Good one!
I started watching your videos when brackys testing your game
I really did need this. Thank you Noa
awesome...can u make a video of how to do wall jumps and slope detection?(and player takes the appropriate angle)
can you help me ? that script is not work for me , i must press up arrow over and over after my character pass the ladder collider (the character climb when his collider over the ladder)and can climb but the gravity never set back to 0, so i must back to the ladder collider to get the gravity again, help
If its not working for anyone make sure you type GetKey. Not GetKeyDown
This video is very helpful, but can you add more animation please!
Please make a video on climbing slopes... Please.
Great Video, love the enthusiasm. Is there any resources you can point us to, to help with jumping off the ladder while gravity is still set to 0, I am having a hard time figuring this one out.
Nice! I had no idea about the one way collider :O
Now to figure out going down the ladder.
for some reason mine just got the down arrow to climb down, i didnt do anything different, but i also cant get out of them with the horizontal movement
@@ozmega That's because Input.GetAxis("Vertical") gets both up and down input in a range from -1 to +1.
If you press down, you have inputVertical(now -1)*speed.
If this helped you understand the reason better, please consider subscribing to my channel.
Thanks great tutorial, covers so much ground :)
DO MULTIPLAYER OR ELSE! (Satire, you are unity hero!)
Do you have a name for the little square guy? He's cute.
How about "Blox"?
I like Blox :) ! Blox it is !
can you do a tutorial where if you already had a player controller, and you just want to climb the ladder?
did you find a way to do that?
Yes?
You literally just add this code to your script wtf man
love you, you've been so helpful. It works just fine :)
What if I want to come down after climbing the ladder fully?
Jepson Art and more Stuff I guess you should watch this video -> ua-cam.com/video/M_kg7yjuhNg/v-deo.html
Input.GetAxis("vertical") will return 1 if you press up and -1 if you press down, so this already implemented in this video's code.
Wow how fast you update your tutorial! I like that all of them. Can you make one tutorial one player can Sprint when he was jumping. I saw you many vedio using that parts. Anyway, Each tutorial I followed by my laptop and I really enjoy your vedio! Thanks so much !
Helped me was in need for something like this !!
Excellent job YOU ROCK!!
this is so awesome!
Hey Noa can you make a tutorial on a block placing system in unity 2d
Your videos are so great. Keep going like that.
MAKE IT EASY!
Game development must be as funny as gameplays!! ^_^
Thanks :) ! Yep game making can is as great as playing games, and even more rewarding !
I am starting on game developing and trying to learn 2D basics. The way you teach is so great and that's why I said that. Keep going and I hope you can make an inventory system any time on the channel. It will help me so much :D
Your welcome and cya :')
Thx man
Hey man! great tutorials. i just have a question and i cant seem to make it work. once i reach the ladder and press the up key, my character just flies away. i have no idea what is going on. any idea what im doing wrong? cheers
did you figure it out? same issue with me
You assigned the jump button to the Up arrow key, making it jump when the function changes to zero gravity.
Check the red note at 5:26
Thanks bro, can You to make videotutorial on Ledge climb.
Could you make a video on adding Multiplayer to this please???
Please like if you agree.
nice work
i have to clik a lot of times on the up arrow so it can work.
any idea why?
THANK YOU SO MUCH AGH
Great video, how about ladder jumping mate
Just enable jumping while on ladder?
Something like:
If (isClimbingLadder)
canJump = true;
If (canJump && Input.GetKey("Jump"))
Jump();
please make tutorial on how to making character climbing and swinging on rope system in unity 3d
Nice one :)
could you do wall jumping and climbing?
Yea, but every tutorial shows platforms away from the ladder,I want the platforms right up to the ladder so you can walk across and have 2 way walking up and down later without top platform collider in the way.
i think you should add "2D" after LADDERS in the title ;)
True enough :) ! I'll add that straight away !
can u plz make a video for 1st person shooter climbing ladder
Thanks
Please make a tutorial on making a Snake game movement? Plaease
What mining game was that at the beginning of the video?
gimme more 2d aww yisss 😂😂 i am trying to make a game like "duck game"
Great video, but the {} formating gave me a headache
How can i apply this using UI buttons ???
Have a function that the UI button calls when pressed. In that function set a bool. Use the bool instead of GetAxis.
all works well , but i have to press Uparrow many times to climb , when it's supposed to hold the Uparrow key to climb , what am i doing wrong ?
ive checked the gravityScale , once i press Uparrow it becomes 0 and goes back to 5 very quickly i barely notice it changes
This happened to me as well but I fixed it. I forgot to add the following section:
if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow))
{
isClimbing = false;
}
}
check if this section is as its supposed to be. Hope this helps!
@@taij.9961 where do i put it
Use GetKey instead of GetKeyDown.
Tai's comment has nothing to do with anything.
@@beri4138 I stopped working on that project and started a new one 😂, thanks for replying 🙏😊
Hi how would you add an animation?? Could you do a video please??
Its working, but I can only climb ladders when Im on the ground, and not in the air. Why?
Hey, can you please try replying asap? (also awesome quality videos
Hey :) ! Nop I've not actually made yet a tutorial on animation transitions (with Unity's Animator Controller)! But making such a video is definitely on my to do list :) !
Just call Animator.SetBool() for a boolean that is true if your input != 0 and make an animation transition in your character's animator from your idle animation to the walk animation if said boolean is true and back to idle if it's not.
how do you code springs?
This solution has a bug. When u jump before the colliding the ladder, and then collide it - u fly very fast cuz gravity becomes zero;
i have the same issue, advice?
@@sarahcruz2103 Set the rigidbody's vertical speed to some constant value when climbing the ladder. It will override whatever speed you had before.
rb.velocity.y = climbspeed;
I've got this code working in my game but for some reason, it only works when the scene is "preloaded" and played from the editor but when I load it in while playing via a button it doesn't work and I don't know what to do...
Can anyone tell me what is the game that Noa was playing at 7:26
celeste
Awesome game btw
Hi, when i try to go up to stairs, automatically the gravity Scale is going to 1 (like, just for 1 frame goes to 0 and then is going back to 1), also, detect the ladder just for 1 frame, idk whats is happening :/
(I dont speak english, but i hope you can understand)
Hey I need help I'm trying this out exactly yet my box keeps slowly sliding off if it isnt dead center to the ladder. Can someone put any possibilities?
doesn't work, my character is look like jumping when i holde up arrow key, then he back land to the ground...help
You probably didn't set the gravityscale to 0
@@joeym2383 I set mine to 0 but it still does it
@@vidgrod695 Did you set the layer of the ladders?
@@joelpersson9146 Yup, I think its just messing with my player controller code.
@@vidgrod695 did you set the ray distance in the Inspector? had the same problem until i realised it's set to 0 which means that my Player shoots a ray up with no distance -> no ladder detected -> player jumps instead of climb
for some reason my characters raycast finds it hard to collide with the damn ladder does anyone know what could be the problem?
don't know if you figured it out but use get key instead of getkeydown works great now
When I push up arrow key he going up when I dont press the up arrow key and he stop it's work but if I keep pushing the up arrow key my player going to clouds and hangs in the air why he doesnt fall the ground.
It work. Finally. It is necessary to pay attention to this sign next to the else and if commands "{" it does not work if you do not write it properly. Be careful if you type the code inside or outside this --> "{".
private void FixedUpdate()
{
inputHorizontal = Input.GetAxisRaw("Horizontal");
rb2d.velocity = new Vector2(inputHorizontal * speed, rb2d.velocity.y);
RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector2.up, distance, whatIsLadder);
if(hitInfo.collider != null)
{
if(Input.GetKey(KeyCode.W))
{
isClimbing = true;
}
}
else
{
rb2d.gravityScale = 5;
isClimbing = false;
}
if(isClimbing == true)
{
inputVertical = Input.GetAxisRaw("Vertical");
rb2d.velocity = new Vector2(rb2d.velocity.x, inputVertical * speed);
rb2d.gravityScale = 0;
}
else
{
rb2d.gravityScale = 5;
}
}//fixedUpdate end
here is my code. copy and paste this I hope it work your project :)
at this point i have literaly copy pasted the code and it is not working as it shoud, most of the times it just doesnt work, but when it does when i press the "up" key on the ladder my "player" does a jump instead of letting me move up and down, also every time i try to use the ladder the "player" gets pushed to the left
{
public Rigidbody2D rb;
public float horizontal;
public float vertical;
public float speed = 3f;
private bool onladder;
public float distance;
public LayerMask ladder;
public float climbingspeed = 4f;
//this a movement script
void FixedUpdate()
{
horizontal = Input.GetAxisRaw("Horizontal");
rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector2.up, distance, ladder);
if (hitInfo.collider != null)
{
if (Input.GetKey("w"))
{
onladder = true;
}
else
{
onladder = false;
}
}
if (onladder == true)
{
vertical = Input.GetAxisRaw("Vertical");
rb.velocity = new Vector2(rb.velocity.x,vertical*climbingspeed);
rb.gravityScale =0;
}
else
{
rb.gravityScale = 5;
}
}
}
that changed nothing is not the keys that dont work, is the gravity that is not working, plus "GetKey("W")" doesnt exist
@@notNNK yeah i noticed it you should add the following code:
if(Input.GetKey("a")
{
onladder =false
}
if(Input.GetKey("d")
{
onladder =false
}
I think you don't need to put the movement code there, it's already in your previous videos...
The character doesn't fall down when I press left or right (It falls with a very low speed) but when I release the button it falls like it supposed to be. Why this happens?
I would just recheck the code. Make sure you have it right, your probably missing a piece. Or your changed gravity could be low. He used 5, so use a number around their. Hope this helps!
hello i have a simple question i want to know how i can disappearance and appearance an object in 2d game
You can use the alpha channel of SpriteRenderer to set transparency.
5Th :D?
no ladder climbing happens for me :/
Mine isn't working, Do you guys know why it isn't? It goes up for a seconds and then falls back down.
any luck?
please help! I cant move my character. Do I need write a script for my character to move?
Yes, you should be able to move by writing the script showed in the video, once you write it drag and drop it into your character and don't forget to set your speed
Omg
Why do you use raycasting inside an update loop when the documentation explicitly states its computationally expensive and is bad practice. A box collider or layer based collision makes more sense?
It's ok he's not making gta 6
if (hitInfo.collider != null)
{
if (Input.GetKeyDown(KeyCode.UpArrow) || !isGrounded)
{
isClimbing = true;
}
}
And how to jump up the ladder 0:25
hey, my character wont latch onto the ladder. Please help :(
Make rb.velocity.x = 0 while climbing the ladder.
This just dont work for me
What if I use GetAxisRaw("Vertical")? Mediocre tutorials, as usual.
What?
What?
It looks too bad without animation...
Second!
i recently started unity as developer but i known basics concepts about C#..... am not good in coding, how i will become a good developer????
Arretes de sécher et vient en cours.
not ver good for begginers you are too fast and in your code are some weird spaces :(
Easy?
First 😁
Damn!
Ok, but those ladders are shit. Heroe is not center