Is it possible to make a spritesheet with two collision shapes?

I don’t know if Phaser allows it, but I want to make two collision shapes for the player, one for hitbox of enemy attacks and another for interactions with the map. Like the image below:

Capturar

On a more realistic game, the player could pass through with no problems, in other words, I need a collision close to the feet of the player and one to the full body for taking damage

Hi,
It isn’t possible to add another body.
Just reducing body size is enough, from mid head to foot, without the legs, and so player doesn’t get hit on transparent pixels. It’s the way old games are made (like megaman…)

2 Likes

I’m facing the same problem, although I’m not sure I understand your answer. Could you please explain a bit more?

I’m using a slightly tall character’s spritesheet with animations and I want two different collisions, for bullet hit and for map. I only want the map to collide with the players legs.

How do I enable collision only on non-transparent pixels?

No, what i said is to reduce the size of the body, example:
The sprite width is 16px, but there is 4px of transparent pixels each side.
So the body must have a width of 8px, and an offset of 4px to be centered

Hi, I did something similar long time ago with Phaser 2, not sure how to do it now with Phaser 3, but just some ideas…

  • Option 1: Try to use the char sprite divided as 2 sprites feet+body (2 hit bodies) attached (sync X, Y)
  • Option 2: Try to use the char sprite with reduced hit body, and another one transparent over (as another body)
  • Make the collisions using groups, all buildings colliding with feet body (purple), all bullets colliding with char body (green)

Maybe this also helps

1 Like

I would resize the sprite’s body to include his feet only, and then add a physics-enabled Zone as a damage box. Reposition the Zone on the player every frame.