How can a character with platform behaviour go up X pixels when colliding with an elevated solid?

0 favourites
  • 5 posts
From the Asset Store
Vintage steam pixels for your UI! 125 unique assets in a single pack!
  • Assuming we have a character (spr_character) with platform behaviour (with default values) and a solid (spr_solid).

    The character is resting on top of a long instance of the solid, and we start moving to the right.

    At some point, we encounter another instant of the solid, which is just 1 pixel higher than the first solid we are walking on top of.

    When the collission occurs, the character GOES UP that one pixel while continueing its movement to the right.

    However, if the extra height of this second solid had been 2 pixels or higher, the character would have gotten stuck there.

    How can I make it so the character can overcome these differences in altitute when they are higher than 1 pixel?

    In a sense, this would be similar to how Terraria characters move. You can walk through the map and not get stuck unless the difference in height is too much, in which case you would have to jump.

    Thank you in advance for your time and cooperation. :)

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can angle the collision angle to solve this.

  • That solution changing the bottom of the collision polygon does work, but I remember encountering some weird glitches if I did that, so I'm not sure if I'd recommend it.

    IIrc construct has a build in (hardcoded) threshhold of how far up a sprite can go instead of getting stuck. But a quick test gave me inconsistent results. Sometimes I'd get stuck at 2px already, sometimes I got stuck at 5px. Not sure what to make of that.

    Anyway, perhaps you can design your game to not have such singular pixel differences?

  • That solution changing the bottom of the collision polygon does work, but I remember encountering some weird glitches if I did that, so I'm not sure if I'd recommend it.

    IIrc construct has a build in (hardcoded) threshhold of how far up a sprite can go instead of getting stuck. But a quick test gave me inconsistent results. Sometimes I'd get stuck at 2px already, sometimes I got stuck at 5px. Not sure what to make of that.

    Anyway, perhaps you can design your game to not have such singular pixel differences?

    I need to see a concrete example of a problem. To understand how to solve it.

  • Hi both,

    Thank you for your replies.

    I ended up making another solid, and gave it a completely linear collision polygon similarly to what igortyhon has suggested.

    This way there's no problem to solve because it's an upwards diagonal line the character will be walking on top of.

    For the time being, that should do the trick.

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