Animation flickering on edge of platform

I have a Player that has animations of Idle and Jumping. Each has a hitbox covering the entire sprite:


Since the Idle animation has a hitbox that is 20px narrower (10px on each side), it is causing the Player object to flicker between the two animations when it gets to the edge of a platform. I think this is because when starting in Idle and falls it switches to Jumping, which causes the wider hitbox, so it thinks it’s on a platform again which causes it to go back to Idle…and the cycle repeats:


I tried to fix this by giving the Jumping animation the same hitbox as the Idle animation:


This solves the flicker issue, but then causes a 10px overlap when the Jumping animation is up against another object or the edge of the screen:


I tried changing the image for the Jumping animation to make it 20px narrower…it works, but I don’t like the image as much. I also tried adding a hidden trigger to the edge of the platform so that when the Player was in collision with the tigger and falling that it pushed the player 10px, but that caused the screen to jump noticeably and looked like a glitch.

I’m wondering if I’m just overlooking something very simple here. It’s not a huge issue, but it has been bothering be for two years now so I thought I’d see if the forum had any ideas. Thanks!

What you’re describing is due to using sprites with different hitboxes per animation. Because your hitbox changes, so does the available space for collision detection.

You need to separate your art assets (sprite with animations) entirely from your platformer character object.

You can do this by having a normal square (that matches your “normal” character size) that doesn’t change size at all depending on animation. You add the platformer character behavior to it. Then you just place another object with your character sprite, and use events to keep it’s position linked with the actual platformer object.

If you look at the built in platformer example, it is set up this wya.

Thank you for your insight, @Silver-Streak.

As I mentioned, I know it’s because of different hitboxes. When I made both animations have the same hitbox, I ran into the overlapping issue. I’ve never really understood the reason behind having a CharacterHitBox, but I tried it anyway and ran into the same overlapping issue.

I guess I’ll just have to decide which is the lesser of two evils and live with it.

Most movement hitboxes are not the full size of the sprite, and overlap happens. If you want your character to not overlap with the wall, you should adjust the width to match the largest width hitbox, or combine multiple hitboxes objects.

As an example, here are the collision boxes for Castlevania: Symphony of the Night:

You can see that the character, Richter, has a collision box that is much smaller than his actual sprite. That collision box allows his sprite to overlap with the wall if he’s pushing up against it.

Note: The collision box (used for movement) IS NOT his hitbox (used for damage detection). In GDevelop terms, you would use the fixed size (smaller) collision box object for movement. You would then set up your events to test against your sprite hitboxes, which you’ve customized per animation for your needs.

If you don’t want the jump animation to not overlap, your only real option would be to make your collision box object the same width as your widest sprite, and not change its size.