Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Joncom

I was wondering if there was a simple way to specify what part of my player will be affected by collision.

My player is 16x32. However, I'd like the game engine to act as if he's only 16x16, and set collisions to the bottom half (his feet).

Regards.

[edit] Having looked around some more, can this be done using the offset attribute of an entity?

1 decade ago by Hareesun

Yeah. Basically just set the player to be 16x16 and have an offset of -16 I think it is. :)

1 decade ago by quidmonkey

offset: { x: 0, y: 8 }

.offset is applied to both sides. Since you want your width to stay the same, x = 0; but for your height, you need to slice off 16 pixels or 8x2 from either end, so y = 8.

Use the Show Collision Boxes in Debug mode for help.

1 decade ago by Joncom

Thanks for your response! It turned out my player.size was 16x32 (just like the sprite graphic), which made the collision/hit box bigger than the 16x16 I wanted it to be.

Fixing the size, and adding a y offset of 16 pixels moved the hit box to the bottom half, just like I wanted. Cheers.
Page 1 of 1
« first « previous next › last »