Arcade physics hitbox based on sprite

Hi,

In Arcade physics is it possible to change the hit box to wrap a sprite nicely (like perfectly around the shape of a space ship for example) or do i need to use another physics lib to do that?

Thanks!

You can change the size of the body associated with the arcade physics sprite.

mySprite.body.setSize(25, 32);
mySprite.body.setOffset(12, 5);

Thanks for that Bill but does not answer the question at all. I am aware that you can change the size and offset of the boxes, but i would like a custom shape not a box.

Ah I understand now. With Arcade Physics I believe the answer is no. You can change the body to be a circle instead of a rectangle, but that’s the only other shape you can use.

Check out it’s API documentation - https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html

1 Like