Wall climbing similar to Prince of Persia - weird issue

Get help using Construct 2

Post » Mon Oct 09, 2017 3:57 am

Hi, I'm trying to make wall climbing similar to the original Prince of Persia. I don't know if this is the best way to go about it, but I have it set so that if the player hitbox is overlapping a wall by an x offset and presses the z key a climb animation will play. When the climb animation finishes it then teleports the player hitbox to an image point on top of the wall so that it is in the correct position to continue play.

My player hitbox is 16x32 and the pivot point is in the middle of this. So to get the player flush against the top of the wall after they've climbed it I have my wall's image point set to y -16. What happens though is weird - when the hitbox teleports to the wall's image point, instead of being on the ground flush as you would expect it to, it instead triggers the fall animation - and messes everything up.

What is interesting, is if I compensate by one extra pixel and set the wall's image point to -17 it works almost perfectly, however there is then a weird 1 pixel gap between the player hitbox and the top of the wall - it just kind of hovers there as if the platform behaviour has forgotten about gravity. If you jump or walk, it will then return to the ground correctly. Is this some kind of bug in the platform behaviour?

I have pixel rounding on, for the record.

Is there a better way I could achieve this sort of Prince of Persia style climbing?

CAPX attached for anyone who can take a look :)

Thanks for any insight!

Link to CAPX
B
66
S
25
G
4
Posts: 211
Reputation: 7,057

Post » Mon Oct 09, 2017 6:19 am

I think with image point set to -16, the hitbox collides with the floor after you teleport it, and is bounced a fraction of a pixel up, that's why its state briefly changes to falling.

If you run your game in debug mode, you'll see that there is always a tiny gap between the hitbox and the floor. Hitbox Y position is something like 63.96 after climbing on the wall, not 64.

Try changing the "hitbox->Set position to wall" to this:
hitbox -> Set position to -> (wall.ImagepointX(1) , wall.ImagepointY(1)+0.6)

As a result, after you teleport it, there will be 0.4 pixels between the hitbox and the floor, so no collision. And these 0.4px will be rounded to 0, so no gap will be seen.
Not sure if this is the best solution, but it works.


Alternatively, you can add some extra checks to your "Platform is falling" event, to not change animation if the player has just climbed the wall and is not actually falling.
Check out my awesome game Doptrix
B
17
S
9
G
28
Posts: 515
Reputation: 16,329

Post » Mon Oct 09, 2017 9:53 am

Thanks very much for the imagepoint solution, it seems to work well so I'm going with it! :D
B
66
S
25
G
4
Posts: 211
Reputation: 7,057

Post » Mon Oct 09, 2017 10:59 am

Happy to help!
Check out my awesome game Doptrix
B
17
S
9
G
28
Posts: 515
Reputation: 16,329


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 42 guests