# setDisplaySize not working properly in matter

**URL:** <https://phaser.discourse.group/t/setdisplaysize-not-working-properly-in-matter/14689>\
**Category:** Phaser 3\
**Created:** [August 28, 2024, 10:31pm UTC](https://phaser.discourse.group/t/setdisplaysize-not-working-properly-in-matter/14689 "2024-08-28T22:31:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohio](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@ohio](https://phaser.discourse.group/u/ohio)\
**Post date:** [August 28, 2024, 10:31pm UTC](https://phaser.discourse.group/t/setdisplaysize-not-working-properly-in-matter/14689/1 "2024-08-28T22:31:54Z")

</div>

When I use setDisplaySize in matter, the image is the correct size, but the hitbox is way too big, how can I fix this?

---

<div class="post-metadata">

**Author:** ![ohio](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@ohio](https://phaser.discourse.group/u/ohio)\
**Post date:** [August 28, 2024, 10:33pm UTC](https://phaser.discourse.group/t/setdisplaysize-not-working-properly-in-matter/14689/2 "2024-08-28T22:33:46Z")

</div>

an acceptable solution would be to fill the whole hitbox area with a color, but that is not ideal.

---

<div class="post-metadata">

**Author:** ![ohio](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@ohio](https://phaser.discourse.group/u/ohio)\
**Post date:** [August 31, 2024, 2:23pm UTC](https://phaser.discourse.group/t/setdisplaysize-not-working-properly-in-matter/14689/3 "2024-08-31T14:23:05Z")

</div>

this will work

```javascript
//before changing the hitbox, only add functions that will change the image of the object, but not the hitbox
this.sprite = this.matter.add.sprite(100, 100, ' ').setDisplaySize(width, height).setTintFill(0x00ff00); 
// in matter, setDisplaySize will make the hitbox much bigger than needed but the image will be the correct size

//changing the hitbox here
this.sprite.setBody({
      type: 'rectangle',
      width: 600, //can do whatever width or height you want
      height: 50
});

//add functions to the sprite that will affect the hitbox AFTER changing the hitbox
this.sprite.setAngle(angle);
this.sprite.setStatic(true);

```
