0 Favourites

Weird slope behavior [Solved]

  • Hello everyone

    I read a bunch of stuff about slopes around here, but most of them is related to how to set the angle to match the slope, which is not the case here.

    I'm developing this game that kinda looks like Mega Man X, and I'm trying to set some slopes so the player can move up and down on the stage without the need of jumping a lot.

    Just setting the slope as a sprite and adjusting the hit box is working fine most of the times but the problem is, my character has a fall and landing animation and every time I'm moving on a slope instead of just moving, there are also some random falls, which completely ruins the game play since have a fall and landing animation randomly happening in the middle of a run or whatever is really ugly and annoying.

    The hit box of the slope is the default bounding box but with one less point on it, so I'm assuming it is a 45 degree angle, and the player has a squared hit box for all frames of all animations.

    Is there any other way to work with slopes? Is this common to construct2? Is there a specific way to set the hit boxes to avoid this kind of behavior? Has anyone else faced this?

    Thank you very much for you attention

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I haven't tried this in Construct 2 specifically, however this concept is more theoretical so it should apply just fine in Construct 2.

    Your problem is the player's sprite's collider set as a box. Since the floor is a slope and the player's collider is a box, this happens. To evade this problem change the bottom part of the collider to be more like a circle. This would nullify the "falling" and ugly stuff that happens.

    That said, if you are using Physics then you may want to make sure that your collider is balanced so the sprite doesn't fall when moving/standing still (i.e. the right side of the sprite is exactly equal and identical to the left side).

    You can achieve this two ways:

    1- Editing the sprite's collider directly and try to make it a bit spherical at the bottom (not really recommended).

    2- Create your player sprite, remove its bottom collider part. Create another object that is invisible and pin it to the player's sprite. In the new object, set the sprite's bounding box to look as spherical as possible.

    Hope that helps!

  • Well, setting the bottom collider to a spherical shape did not help at all. However editing the collision box helped me realize that small 1px changes between one animation and the other were causing this problem.

    Actually, even inside the animation it self, if the half of the collision box that was drawn after the origin point had a different size than the left half the movement wouldn't be smooth and cause the random falls.

    After adjusting the hit box of each animation TT.TT The game and its slopes are working just fine.

    Thank you very much for the support, you shed light to a matter I couldn't see before and it helped me a lot.

  • the fool-proof way is to have a rectangular sprite as the behavior hitbox, then pin the graphics over it.

    "Implementing reliable platform movements

    For the most reliable platform movement, it is recommended to use a invisible rectangle sprite with no animations with the Platform movement. Then, the animated player object can be positioned on top of that. Otherwise, the changing size and collision polygon of the object as its animation plays can interfere with the Platform movement's floor, wall and slope detection, causing a shaking or glitchy movement. For more information and a complete guide, see the tutorial How to make a Platform game."

    source : https://www.scirra.com/manual/100/platform

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