Getting character to climb a ladder with a click

Get help using Construct 2

Post » Sat Jan 25, 2014 10:47 pm

Hey guys,

I'm running out of ideas here.
I'm trying to make a point n' click platformer with some pathfinding.
I want the character to climb ladders when they are clicked and go down if he is upstairs.
I find my implementation logical but it doesn't seem to be getting the work done.
Could somebody explain me why?
I'm attaching the project here.


Thanks!

https://www.dropbox.com/s/62fbk8fo8l6a59e/pointnclickplat.capx
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Sun Jan 26, 2014 1:11 am

Can't link on this site yet so just go to the tutorials and search for ladders, there's a slick tut called "A Simple Method for Climbing Ladders in Platformers", I think this will help you.
There are 10 types of people in the World, those that understand binary and those who don't.
B
7
S
2
Posts: 93
Reputation: 797

Post » Sun Jan 26, 2014 1:59 am

Bertie,
Thank you for the suggestion but I know how to do what's explained in that tutorial. I need help specifically with my point n' click situation, which is different.

Thanks!
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Mon Jan 27, 2014 12:59 am

can't seem to download your example file right now, but here's how i would do it.

create 2 image points for your ladder. (1 = top of ladder, 2 = bottom of ladder)

On mouse click on object "ladder".
(sub event) system compare 2 values distance(player.x, player.y, ladder.ImagePointX(1), ladder.imagePointY(1))

< distance(player.x, player.y, ladder.ImagePointX(2), ladder.imagePointY(2))

This checks the distance between the player and the 2 image points. If image point 1 is closer to the player, then you know he's near the top of the ladder, if point 2 is closer, then he's closer to the bottom of the ladder.

Next, move the player automatically to the proper imagepoint location, then play the ladder climbing animation, while he automatically moves the other image point.
B
90
S
44
G
17
Posts: 1,012
Reputation: 18,527

Post » Mon Jan 27, 2014 7:01 pm

I think that's pretty much what I did!
I'm kind of proud my logic made sense then :D But I still must be doing something wrong.
I don't understand why you can't download the file :S Just sent it to a friend and it seems to work.
Would you mind trying again, please?
Here's a screenshot of my eventsheet just in case.
http://i.imgur.com/BCvcmLG.png
B
8
S
2
Posts: 39
Reputation: 1,492

Post » Mon Jan 27, 2014 7:32 pm

Ok, so there are multiple problems here. (I managed to download/test it).

First, name your sprites. I renamed them, it's a lot more simple to read.
Second, you don't use the pathfinding behavior right. First "Find path", then in another event, you use the trigger "on path found", and then you move along path. I changed it in the code.
Using this correctly, and using image points where I want the character to go exactly (in the **middle** of the top and bottom sides), it works more like you wanted it.
Another problem there were was the top of the ladder not being solid, and we would fall through as the platform behavior was resumed. You may have did it so the pathfinding works, but I put again the solid behavior, witch I deactivated, as well as the collisions, in the editor. I activate them as soon as you click on the first ladder. The pathfinding won't be bothered by the solid, as it has already calculated its obstacle map.

Here is the link.

Feel free to ask if anything isn't clear :)Guizmus2014-01-27 19:34:38
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Mon Feb 10, 2014 3:06 am

This comes like 2 weeks late but, thank you very much Guizmus! That made it very clear for me. Awesome.
B
8
S
2
Posts: 39
Reputation: 1,492


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 22 guests