Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am creating a platform game, and the main character has three images for its left and right animation. The problem is that when it is walking and the player run into a block, if at that moment it switches to a stepping image which is bigger than the other imagesit gets stuck inside the block. A temporary fix to this issue was to make all the images the same size and just fill the smaller ones with white-space, however that doesn't work properly either because then the collision box is bigger than the player. Any suggestions? I also tried stretching all the images to the same size but that looked ugly.

share|improve this question
    
Is your collision box size changing? Does every pixel of your sprite have to be inside the collision box? –  UnderscoreZero Jun 7 '13 at 15:36
    
I added a picture to my answer. –  Nick Caplinger Jun 7 '13 at 17:09

1 Answer 1

up vote 3 down vote accepted

You should create size values that are separate from the image size. This is often called a "hitbox". This way, you can add an image of any size with any given amount of whitespace, and collisions will be unaffected.

Mario Hitboxes

Fighting games use multiple hitboxes to handle complex collisions.

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.