My sprite's colliding with object, even if there's no pixel colliding with other objects

I’m having trouble with my sprite/player. The canvas size is wider when running than standing still; therefor the “Idle” animation has “empty spaces” on both sides of it, when standing still. But, when I’m jumping to a platform it’s like the players animation for jumping or idle is wider than it is. I mean, it IS wider than it seems, but it’s PNG with no “painted pixels” at the sides (if you get what I mean…) so I thought it wouldn’t matter? If I shorten the “Idle” animation, it looks weird when going to “running” and it just won’t fit nicely.
Guess I’m doing a real newbie misstake and I’m thankful for any help!
Posting a picture to illustrate my problem.

Hi,

I may have had a similar issue.

I had to make sure that the images for my sprite were all the same size no matter what they were doing, then edit the hitbox (you can use the X/Y coords to keep them as uniform as possible).

I would choose the canvas size that best accommodates your largest image and stick with that for all of them. The hitbox will control the actual contact with surfaces, if that makes sense.

All right! I’m totally new at this… where do I edit the hitbox?

Right now all the canvases/animations for the character are the same size, e.g the largest one - and that’s how it should be, you mean? Will changing the hitbox help fix the fact that most of the canvases (for example Idle) isn’t that wide at all, leaving empty spaces besides the character? So he won’t be standing in the air next to a platform? Thank you for your help!

Open up your player sprite and scroll down to the bottom of the animations, then click “edit hitboxes”. There are options that let you have different hitboxes for each animation or share across all of them - I would keep that enabled so you don’t have to do it over and over. Check out this page on the wiki for a visual on where to find the button, it’s under the section “Adding multiple animations”. :slight_smile:

http://wiki.compilgames.net/doku.php/gdevelop5/objects/sprite#collision_and_points

Here are a couple shots of the hitbox on my player sprite’s idle animation.

The first is from a level that has platforms with small spaces between them. Players can fall through if they aren’t careful even though the sprite canvas size is larger (it’s as big as the black square) because of the hitbox.

hitboxex1

The second shows the X and Y coordinates - you’ll need to click the plus sign initially to get those fields. You can drag the red dots around, but I found it easier to set their final positions by number to make them even.

I believe this will fix the issue. Hope so anyway! Let me know if there’s something else.

You’re welcome :smiley:

Did that work or are you still having trouble?

It worked! Thanks a lot!
But now I’ve got a new problem :sweat_smile:

I’ve made an enemy, who’s got an animation that’s pretty wide (jumping and rolling forward) and when I try to change the hit box, I can’t get to the far right where my character start the animation. Can I change this somehow, or must I change the animation “in place” and instead use some sort of path logic to move it forward?

Great! You’re welcome :grin:

Ooo, I would probably do an ‘in place’ animation for that and then use events to move it.

I notice you have the sharing collision masks set to ‘off’, is that because he’s in different parts of the image? Just curious :slight_smile:

Cool looking enemy, btw!

Yeah, I figured - so I changed it to a smaller animation; going right up instead (haven’t learned events with paths and stuff yet :sweat_smile:)

Exactly, that’s why I turned it off.

Thanks!

Another problem: I can’t get my player change animation to look to the left when standing still facing that direction; he’s always facing right. I’ve used the events/actions suggested in the ”Platformer” tutorial.

Again, thanks for your help!

1 Like

You’re welcome :slight_smile:

Can you post a screenshot of those events?

Do the frames of your animations all face the same direction?

My best guess, without seeing your events, is that you may be missing the “flip horizontal” action or it doesn’t have the right ‘yes/no’ setting for the direction. There can be other things that might be throwing it off too.

I haven’t done much experimenting with the path-finding behavior yet either :sweat_smile:

as @Phenomena says you are probably missing the flip event.
Post events as said it will be easier to help