Wall climbing similar to Prince of Persia - weird issue

0 favourites
  • 4 posts
From the Asset Store
Wall Pin Board is a hyper causal game developed for fun and inspired by YouTube video whose link is given in description
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Thanks very much for the imagepoint solution, it seems to work well so I'm going with it!

  • Happy to help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)