[Solved] Climbing a ladder

Get help using Construct 2

Post » Sun Oct 16, 2011 12:20 am

Hi

Quick question. How do I make my character climb a ladder?

I think I know roughly the basics of how it would work??? I'm thinking when player overlaps object ladder and Up Arrow key is pressed, "Set Y to Player.Y-3".

But this moves the player up by -3. He then drops down. I want it so for as long as the key is held down and he is overlapping the ladder, he will climb. I also want it so when the key is released he won't fall back down.

I'm sure you have all seen it before, it's the behaviour you'll find in most platformers we have all ever played.

Thanks in advance for your help.FredQ2011-10-16 10:16:56
ImageImage
Mr. Green - Platform/puzzle game out now!
B
24
S
7
G
1
Posts: 222
Reputation: 3,325

Post » Sun Oct 16, 2011 12:28 am

Well, you'd have to set the gravity to 0 while you're on the ladder or else you'll fall back down. And your event should say Up Arrow is down, rather than is pressed -- "is pressed" will only make it happen once.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Oct 16, 2011 12:39 am

This is one way to do it:

Perhaps give the sprite a variable called climb, then when you press Up while overlapping a ladder set the variable to 1. For another event, check if variable = 1, then set Y vector and gravity to 0. As a sub events of the variable = 1, do a check to see if player is jumping off ladder or no longer overlapping ladder (set variable to 0), then another to see if they're pressing Up/down to climb up/down.

I made an example, its not perfect but might give you an idea:
http://dl.dropbox.com/u/1024727/c2/ladderexample.capx
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Sun Oct 16, 2011 12:45 am

Thanks alspal, that's perfect. It would be nice if when the player reached the top of the ladder he could sit at the top rather than dropping down. Is there another event I can add to make this happen?

And thanks for your input too Sully.
ImageImage
Mr. Green - Platform/puzzle game out now!
B
24
S
7
G
1
Posts: 222
Reputation: 3,325

Post » Sun Oct 16, 2011 12:59 am

I decided to be a bit more helpful this time.

http://db.tt/35AUXS8J

I took alspal's example and added a few things: when you get to the top, it spawns an invisible solid object that lets you sit on top of the ladder. When you press down again, it destroys the object to clear the way for you to use the ladder again.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Oct 16, 2011 1:15 am

Perfect! Thank you both for your help. I would never have been able to work that one out for myself lol.

It's great to find a forum with quick, worth-while support.
ImageImage
Mr. Green - Platform/puzzle game out now!
B
24
S
7
G
1
Posts: 222
Reputation: 3,325

Post » Sun Oct 16, 2011 1:21 am

No prob! The community definitely saved me when I was first starting out, so the least I can do is give back.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Oct 16, 2011 1:22 am

Sorry one last thing...

I noticed the object created to support the player was set to a position specific to top of that one ladder.

Is it possible to create the 'supporting' object relative to the players co-ordinates so I can have multiple instances of the same ladder. At the minute, if I create a second ladder, the position of the object created it set to appear only at the top of ladder number one.

I hope this makes sense. I know what I want to ask, I just hope I put it into words clear enough.
ImageImage
Mr. Green - Platform/puzzle game out now!
B
24
S
7
G
1
Posts: 222
Reputation: 3,325

Post » Sun Oct 16, 2011 1:31 am

[QUOTE=SullyTheStrange] No prob! The community definitely saved me when I was first starting out, so the least I can do is give back. [/QUOTE]

And you've been doing awesome so far. Keep up the good support
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun Oct 16, 2011 1:39 am

[QUOTE=FredQ]Is it possible to create the 'supporting' object relative to the players co-ordinates so I can have multiple instances of the same ladder. At the minute, if I create a second ladder, the position of the object created it set to appear only at the top of ladder number one.[/QUOTE]

Oh yeah, you can definitely do that. I updated the example to show how:

http://db.tt/35AUXS8J

There's two major changes. For one thing, in the event where you create the solid object, I added a condition to pick the correct ladder based on distance to the player. It'll pick the one you're standing on top of (unless the ladders are TOO close together -- it might be looking at the center of the ladders and which is closest, so as long as the one you're standing on has the closest center to you, it'll work).

Anyway! The coordinates it spawns at are also changed, so they aren't hardcoded numbers anymore. Instead, it uses the coordinates of the ladder and finds the right spot from there.

One thing the example doesn't do is let you jump from the top of one ladder to another. To fix that, you can disable the "Pick ladder" condition and add in a new one, "For each ladder". You can find that underneath "System" in the list.

Hope that helps!

[QUOTE=Kyatric]And you've been doing awesome so far. Keep up the good support [/QUOTE]

Aww, shucks. You noticed. Haha, thanks a lot!SullyTheStrange2011-10-16 01:43:08
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Rezzon71, tarek2 and 22 guests